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:
Toby Zerner 2015-08-31 14:35:52 +09:30
parent 5e22458014
commit 6c169499b5
3 changed files with 12 additions and 17 deletions

View File

@ -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);

View File

@ -15,14 +15,6 @@ use Illuminate\Events\Dispatcher;
class Extension extends ServiceProvider
{
public function install()
{
}
public function uninstall()
{
}
public function listen(Dispatcher $events)
{
}

View File

@ -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')) {