mirror of
https://github.com/flarum/framework.git
synced 2024-12-05 00:43:39 +08:00
Extensions do not need to know whether they are enabled
This commit is contained in:
parent
101cb1255d
commit
b55ba61f79
|
@ -84,13 +84,6 @@ class Extension implements Arrayable
|
||||||
*/
|
*/
|
||||||
protected $version;
|
protected $version;
|
||||||
|
|
||||||
/**
|
|
||||||
* Whether the extension is enabled.
|
|
||||||
*
|
|
||||||
* @var bool
|
|
||||||
*/
|
|
||||||
protected $enabled = false;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $path
|
* @param $path
|
||||||
* @param array $composerJson
|
* @param array $composerJson
|
||||||
|
@ -226,8 +219,6 @@ class Extension implements Arrayable
|
||||||
|
|
||||||
public function enable(Container $container)
|
public function enable(Container $container)
|
||||||
{
|
{
|
||||||
$this->setEnabled(true);
|
|
||||||
|
|
||||||
foreach ($this->getLifecycleExtenders() as $extender) {
|
foreach ($this->getLifecycleExtenders() as $extender) {
|
||||||
$extender->onEnable($container, $this);
|
$extender->onEnable($container, $this);
|
||||||
}
|
}
|
||||||
|
@ -235,32 +226,11 @@ class Extension implements Arrayable
|
||||||
|
|
||||||
public function disable(Container $container)
|
public function disable(Container $container)
|
||||||
{
|
{
|
||||||
$this->setEnabled(false);
|
|
||||||
|
|
||||||
foreach ($this->getLifecycleExtenders() as $extender) {
|
foreach ($this->getLifecycleExtenders() as $extender) {
|
||||||
$extender->onDisable($container, $this);
|
$extender->onDisable($container, $this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param bool $enabled
|
|
||||||
* @return Extension
|
|
||||||
*/
|
|
||||||
public function setEnabled($enabled)
|
|
||||||
{
|
|
||||||
$this->enabled = $enabled;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
public function isEnabled()
|
|
||||||
{
|
|
||||||
return $this->enabled;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The raw path of the directory under extensions.
|
* The raw path of the directory under extensions.
|
||||||
*
|
*
|
||||||
|
|
|
@ -83,7 +83,6 @@ class ExtensionManager
|
||||||
// Per default all extensions are installed if they are registered in composer.
|
// Per default all extensions are installed if they are registered in composer.
|
||||||
$extension->setInstalled(true);
|
$extension->setInstalled(true);
|
||||||
$extension->setVersion(Arr::get($package, 'version'));
|
$extension->setVersion(Arr::get($package, 'version'));
|
||||||
$extension->setEnabled($this->isEnabled($extension->getId()));
|
|
||||||
|
|
||||||
$extensions->put($extension->getId(), $extension);
|
$extensions->put($extension->getId(), $extension);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user