mirror of
https://github.com/flarum/framework.git
synced 2025-02-21 07:50:24 +08:00
Extensions should be considered enabled after boot.
Before boot, we consider them "disabled" so they get migrated.
This commit is contained in:
parent
d68d551e16
commit
ce7484e2c8
@ -31,6 +31,8 @@ class OverrideExtensionManagerForTests implements ExtenderInterface
|
||||
$extensionManager->enable($extension);
|
||||
}
|
||||
|
||||
$extensionManager->booted = true;
|
||||
|
||||
$extensionManager->extend($container);
|
||||
}
|
||||
}
|
||||
|
@ -30,6 +30,11 @@ class ExtensionManagerIncludeCurrent extends ExtensionManager
|
||||
*/
|
||||
protected $enabledIds;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
public $booted = false;
|
||||
|
||||
public function __construct(
|
||||
SettingsRepositoryInterface $config,
|
||||
Paths $paths,
|
||||
@ -70,11 +75,15 @@ class ExtensionManagerIncludeCurrent extends ExtensionManager
|
||||
}
|
||||
|
||||
/**
|
||||
* Since we enable every time, we always assume it's not enabled.
|
||||
* We assume it's not enabled during boot.
|
||||
* However, since some logic needs this, as soon as we enable extensions
|
||||
* we'll switch booted to on.
|
||||
*/
|
||||
public function isEnabled($extension)
|
||||
{
|
||||
return false;
|
||||
if (!$this->booted) return false;
|
||||
|
||||
return parent::isEnabled($extension);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -125,6 +125,17 @@ class TestCaseTest extends TestCase
|
||||
$this->assertTrue($tableExists);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function current_extension_considered_enabled_after_boot()
|
||||
{
|
||||
$this->extension('flarum-testing-tests');
|
||||
|
||||
$enabled = $this->app()->getContainer()->make('flarum.extensions')->isEnabled('flarum-testing-tests');
|
||||
$this->assertTrue($enabled);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user