mirror of
https://github.com/flarum/framework.git
synced 2025-01-22 18:42:01 +08:00
Only migrate enabled extensions when upgrading
Also remove the Extension::install() and Extension::uninstall() methods, because they add nothing that can't be done with migrations.
This commit is contained in:
parent
5e22458014
commit
6c169499b5
|
@ -68,9 +68,13 @@ class UpgradeCommand extends Command
|
|||
$migrator = $extensions->getMigrator();
|
||||
|
||||
foreach ($extensions->getInfo() as $extension) {
|
||||
if (! $extensions->isEnabled($extension->name)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$this->info('Upgrading extension: '.$extension->name);
|
||||
|
||||
$extensions->enable($extension->name);
|
||||
$extensions->migrate($extension->name);
|
||||
|
||||
foreach ($migrator->getNotes() as $note) {
|
||||
$this->info($note);
|
||||
|
|
|
@ -15,14 +15,6 @@ use Illuminate\Events\Dispatcher;
|
|||
|
||||
class Extension extends ServiceProvider
|
||||
{
|
||||
public function install()
|
||||
{
|
||||
}
|
||||
|
||||
public function uninstall()
|
||||
{
|
||||
}
|
||||
|
||||
public function listen(Dispatcher $events)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -48,15 +48,11 @@ class ExtensionManager
|
|||
|
||||
public function enable($extension)
|
||||
{
|
||||
$enabled = $this->getEnabled();
|
||||
|
||||
if (! in_array($extension, $enabled)) {
|
||||
if (! $this->isEnabled($extension)) {
|
||||
$enabled[] = $extension;
|
||||
|
||||
$class = $this->load($extension);
|
||||
|
||||
$class->install();
|
||||
|
||||
$this->migrate($extension);
|
||||
|
||||
$this->setEnabled($enabled);
|
||||
|
@ -80,12 +76,10 @@ class ExtensionManager
|
|||
|
||||
$class = $this->load($extension);
|
||||
|
||||
$class->uninstall();
|
||||
|
||||
$this->migrate($extension, false);
|
||||
}
|
||||
|
||||
protected function migrate($extension, $up = true)
|
||||
public function migrate($extension, $up = true)
|
||||
{
|
||||
$migrationDir = base_path('../extensions/' . $extension . '/migrations');
|
||||
|
||||
|
@ -119,6 +113,11 @@ class ExtensionManager
|
|||
$this->config->set('extensions_enabled', json_encode($enabled));
|
||||
}
|
||||
|
||||
public function isEnabled($extension)
|
||||
{
|
||||
return in_array($extension, $this->getEnabled());
|
||||
}
|
||||
|
||||
protected function load($extension)
|
||||
{
|
||||
if (file_exists($file = $this->getExtensionsDir() . '/' . $extension . '/bootstrap.php')) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user