mirror of
https://github.com/flarum/core.git
synced 2025-10-12 23:44:27 +02: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:
@@ -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')) {
|
||||
|
Reference in New Issue
Block a user