mirror of
https://github.com/flarum/framework.git
synced 2025-06-03 22:43:10 +08:00
Publish core/extension assets
Core assets are copied into the root/assets directory on installation. The contents of an "assets" directory within any extension is copied into root/assets/extensions/{name}/ whenever the extension is enabled, and deleted whenever the extension is uninstalled. Still needs to be refactored
This commit is contained in:
@ -14,10 +14,11 @@ use Flarum\Core;
|
|||||||
use Flarum\Event\ExtensionWasDisabled;
|
use Flarum\Event\ExtensionWasDisabled;
|
||||||
use Flarum\Event\ExtensionWasEnabled;
|
use Flarum\Event\ExtensionWasEnabled;
|
||||||
use Flarum\Event\ExtensionWasUninstalled;
|
use Flarum\Event\ExtensionWasUninstalled;
|
||||||
|
use Flarum\Foundation\Application;
|
||||||
use Flarum\Settings\SettingsRepository;
|
use Flarum\Settings\SettingsRepository;
|
||||||
use Illuminate\Contracts\Container\Container;
|
|
||||||
use Flarum\Database\Migrator;
|
use Flarum\Database\Migrator;
|
||||||
use Illuminate\Contracts\Events\Dispatcher;
|
use Illuminate\Contracts\Events\Dispatcher;
|
||||||
|
use Illuminate\Filesystem\Filesystem;
|
||||||
|
|
||||||
class ExtensionManager
|
class ExtensionManager
|
||||||
{
|
{
|
||||||
@ -32,12 +33,18 @@ class ExtensionManager
|
|||||||
*/
|
*/
|
||||||
protected $dispatcher;
|
protected $dispatcher;
|
||||||
|
|
||||||
public function __construct(SettingsRepository $config, Container $app, Migrator $migrator, Dispatcher $dispatcher)
|
/**
|
||||||
|
* @var Filesystem
|
||||||
|
*/
|
||||||
|
protected $filesystem;
|
||||||
|
|
||||||
|
public function __construct(SettingsRepository $config, Application $app, Migrator $migrator, Dispatcher $dispatcher, Filesystem $filesystem)
|
||||||
{
|
{
|
||||||
$this->config = $config;
|
$this->config = $config;
|
||||||
$this->app = $app;
|
$this->app = $app;
|
||||||
$this->migrator = $migrator;
|
$this->migrator = $migrator;
|
||||||
$this->dispatcher = $dispatcher;
|
$this->dispatcher = $dispatcher;
|
||||||
|
$this->filesystem = $filesystem;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getInfo()
|
public function getInfo()
|
||||||
@ -137,7 +144,10 @@ class ExtensionManager
|
|||||||
*/
|
*/
|
||||||
protected function publishAssets($extension)
|
protected function publishAssets($extension)
|
||||||
{
|
{
|
||||||
// TODO: implement
|
$this->filesystem->copyDirectory(
|
||||||
|
$this->app->basePath().'/extensions/'.$extension.'/assets',
|
||||||
|
$this->app->basePath().'/assets/extensions/'.$extension
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -147,7 +157,7 @@ class ExtensionManager
|
|||||||
*/
|
*/
|
||||||
protected function unpublishAssets($extension)
|
protected function unpublishAssets($extension)
|
||||||
{
|
{
|
||||||
// TODO: implement
|
$this->filesystem->deleteDirectory($this->app->basePath().'/assets/extensions/'.$extension);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -159,7 +169,7 @@ class ExtensionManager
|
|||||||
*/
|
*/
|
||||||
public function getAsset($extension, $path)
|
public function getAsset($extension, $path)
|
||||||
{
|
{
|
||||||
// TODO: implement
|
return $this->app->basePath().'/assets/extensions/'.$extension.$path;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function migrate($extension, $up = true)
|
public function migrate($extension, $up = true)
|
||||||
|
@ -17,6 +17,7 @@ use Flarum\Core\User;
|
|||||||
use Flarum\Core\Group;
|
use Flarum\Core\Group;
|
||||||
use Flarum\Core\Permission;
|
use Flarum\Core\Permission;
|
||||||
use Illuminate\Contracts\Foundation\Application;
|
use Illuminate\Contracts\Foundation\Application;
|
||||||
|
use Illuminate\Filesystem\Filesystem;
|
||||||
use Illuminate\Support\Arr;
|
use Illuminate\Support\Arr;
|
||||||
use Illuminate\Validation\Factory;
|
use Illuminate\Validation\Factory;
|
||||||
use PDO;
|
use PDO;
|
||||||
@ -38,11 +39,21 @@ class InstallCommand extends AbstractCommand
|
|||||||
*/
|
*/
|
||||||
protected $application;
|
protected $application;
|
||||||
|
|
||||||
public function __construct(Application $application)
|
/**
|
||||||
|
* @var Filesystem
|
||||||
|
*/
|
||||||
|
protected $filesystem;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Application $application
|
||||||
|
* @param Filesystem $filesystem
|
||||||
|
*/
|
||||||
|
public function __construct(Application $application, Filesystem $filesystem)
|
||||||
{
|
{
|
||||||
$this->application = $application;
|
$this->application = $application;
|
||||||
|
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
|
$this->filesystem = $filesystem;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function configure()
|
protected function configure()
|
||||||
@ -331,7 +342,10 @@ class InstallCommand extends AbstractCommand
|
|||||||
|
|
||||||
protected function publishAssets()
|
protected function publishAssets()
|
||||||
{
|
{
|
||||||
// TODO
|
$this->filesystem->copyDirectory(
|
||||||
|
__DIR__.'/../../../assets',
|
||||||
|
$this->application->basePath().'/assets'
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getConfigFile()
|
protected function getConfigFile()
|
||||||
|
Reference in New Issue
Block a user