mirror of
https://github.com/flarum/framework.git
synced 2025-02-22 07:19:56 +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
5f9f42dc4b
commit
9024cabcb3
@ -68,9 +68,13 @@ class UpgradeCommand extends Command
|
|||||||
$migrator = $extensions->getMigrator();
|
$migrator = $extensions->getMigrator();
|
||||||
|
|
||||||
foreach ($extensions->getInfo() as $extension) {
|
foreach ($extensions->getInfo() as $extension) {
|
||||||
|
if (! $extensions->isEnabled($extension->name)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
$this->info('Upgrading extension: '.$extension->name);
|
$this->info('Upgrading extension: '.$extension->name);
|
||||||
|
|
||||||
$extensions->enable($extension->name);
|
$extensions->migrate($extension->name);
|
||||||
|
|
||||||
foreach ($migrator->getNotes() as $note) {
|
foreach ($migrator->getNotes() as $note) {
|
||||||
$this->info($note);
|
$this->info($note);
|
||||||
|
@ -15,14 +15,6 @@ use Illuminate\Events\Dispatcher;
|
|||||||
|
|
||||||
class Extension extends ServiceProvider
|
class Extension extends ServiceProvider
|
||||||
{
|
{
|
||||||
public function install()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public function uninstall()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public function listen(Dispatcher $events)
|
public function listen(Dispatcher $events)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -48,15 +48,11 @@ class ExtensionManager
|
|||||||
|
|
||||||
public function enable($extension)
|
public function enable($extension)
|
||||||
{
|
{
|
||||||
$enabled = $this->getEnabled();
|
if (! $this->isEnabled($extension)) {
|
||||||
|
|
||||||
if (! in_array($extension, $enabled)) {
|
|
||||||
$enabled[] = $extension;
|
$enabled[] = $extension;
|
||||||
|
|
||||||
$class = $this->load($extension);
|
$class = $this->load($extension);
|
||||||
|
|
||||||
$class->install();
|
|
||||||
|
|
||||||
$this->migrate($extension);
|
$this->migrate($extension);
|
||||||
|
|
||||||
$this->setEnabled($enabled);
|
$this->setEnabled($enabled);
|
||||||
@ -80,12 +76,10 @@ class ExtensionManager
|
|||||||
|
|
||||||
$class = $this->load($extension);
|
$class = $this->load($extension);
|
||||||
|
|
||||||
$class->uninstall();
|
|
||||||
|
|
||||||
$this->migrate($extension, false);
|
$this->migrate($extension, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function migrate($extension, $up = true)
|
public function migrate($extension, $up = true)
|
||||||
{
|
{
|
||||||
$migrationDir = base_path('../extensions/' . $extension . '/migrations');
|
$migrationDir = base_path('../extensions/' . $extension . '/migrations');
|
||||||
|
|
||||||
@ -119,6 +113,11 @@ class ExtensionManager
|
|||||||
$this->config->set('extensions_enabled', json_encode($enabled));
|
$this->config->set('extensions_enabled', json_encode($enabled));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function isEnabled($extension)
|
||||||
|
{
|
||||||
|
return in_array($extension, $this->getEnabled());
|
||||||
|
}
|
||||||
|
|
||||||
protected function load($extension)
|
protected function load($extension)
|
||||||
{
|
{
|
||||||
if (file_exists($file = $this->getExtensionsDir() . '/' . $extension . '/bootstrap.php')) {
|
if (file_exists($file = $this->getExtensionsDir() . '/' . $extension . '/bootstrap.php')) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user