mirror of
https://github.com/flarum/framework.git
synced 2024-12-05 09:03:36 +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:
parent
27a2b616c4
commit
efae3def13
|
@ -14,10 +14,11 @@ use Flarum\Core;
|
|||
use Flarum\Event\ExtensionWasDisabled;
|
||||
use Flarum\Event\ExtensionWasEnabled;
|
||||
use Flarum\Event\ExtensionWasUninstalled;
|
||||
use Flarum\Foundation\Application;
|
||||
use Flarum\Settings\SettingsRepository;
|
||||
use Illuminate\Contracts\Container\Container;
|
||||
use Flarum\Database\Migrator;
|
||||
use Illuminate\Contracts\Events\Dispatcher;
|
||||
use Illuminate\Filesystem\Filesystem;
|
||||
|
||||
class ExtensionManager
|
||||
{
|
||||
|
@ -32,12 +33,18 @@ class ExtensionManager
|
|||
*/
|
||||
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->app = $app;
|
||||
$this->migrator = $migrator;
|
||||
$this->dispatcher = $dispatcher;
|
||||
$this->filesystem = $filesystem;
|
||||
}
|
||||
|
||||
public function getInfo()
|
||||
|
@ -137,7 +144,10 @@ class ExtensionManager
|
|||
*/
|
||||
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)
|
||||
{
|
||||
// TODO: implement
|
||||
$this->filesystem->deleteDirectory($this->app->basePath().'/assets/extensions/'.$extension);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -159,7 +169,7 @@ class ExtensionManager
|
|||
*/
|
||||
public function getAsset($extension, $path)
|
||||
{
|
||||
// TODO: implement
|
||||
return $this->app->basePath().'/assets/extensions/'.$extension.$path;
|
||||
}
|
||||
|
||||
public function migrate($extension, $up = true)
|
||||
|
|
|
@ -17,6 +17,7 @@ use Flarum\Core\User;
|
|||
use Flarum\Core\Group;
|
||||
use Flarum\Core\Permission;
|
||||
use Illuminate\Contracts\Foundation\Application;
|
||||
use Illuminate\Filesystem\Filesystem;
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Validation\Factory;
|
||||
use PDO;
|
||||
|
@ -38,11 +39,21 @@ class InstallCommand extends AbstractCommand
|
|||
*/
|
||||
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;
|
||||
|
||||
parent::__construct();
|
||||
$this->filesystem = $filesystem;
|
||||
}
|
||||
|
||||
protected function configure()
|
||||
|
@ -331,7 +342,10 @@ class InstallCommand extends AbstractCommand
|
|||
|
||||
protected function publishAssets()
|
||||
{
|
||||
// TODO
|
||||
$this->filesystem->copyDirectory(
|
||||
__DIR__.'/../../../assets',
|
||||
$this->application->basePath().'/assets'
|
||||
);
|
||||
}
|
||||
|
||||
protected function getConfigFile()
|
||||
|
|
Loading…
Reference in New Issue
Block a user