Add AbstractPicoPlugin::configEnabled()
This commit is contained in:
parent
bbccb374de
commit
581a3a0609
@ -93,7 +93,22 @@ abstract class AbstractPicoPlugin implements PicoPluginInterface
|
||||
{
|
||||
// plugins can be enabled/disabled using the config
|
||||
if ($eventName === 'onConfigLoaded') {
|
||||
$pluginEnabled = $this->getConfig(get_called_class() . '.enabled');
|
||||
$this->configEnabled();
|
||||
}
|
||||
|
||||
if ($this->isEnabled() || ($eventName === 'onPluginsLoaded')) {
|
||||
if (method_exists($this, $eventName)) {
|
||||
call_user_func_array(array($this, $eventName), $params);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables or disables this plugin depending on Pico's config
|
||||
*/
|
||||
protected function configEnabled()
|
||||
{
|
||||
$pluginEnabled = $this->getPico()->getConfig(get_called_class() . '.enabled');
|
||||
if ($pluginEnabled !== null) {
|
||||
$this->setEnabled($pluginEnabled);
|
||||
} else {
|
||||
@ -101,7 +116,7 @@ abstract class AbstractPicoPlugin implements PicoPluginInterface
|
||||
if ($pluginEnabled !== null) {
|
||||
$this->setEnabled($pluginEnabled);
|
||||
} elseif ($this->enabled) {
|
||||
$this->setEnabled($this->enabled, true, true);
|
||||
$this->setEnabled(true, true, true);
|
||||
} elseif ($this->enabled === null) {
|
||||
// make sure dependencies are already fulfilled,
|
||||
// otherwise the plugin needs to be enabled manually
|
||||
@ -114,13 +129,6 @@ abstract class AbstractPicoPlugin implements PicoPluginInterface
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->isEnabled() || ($eventName === 'onPluginsLoaded')) {
|
||||
if (method_exists($this, $eventName)) {
|
||||
call_user_func_array(array($this, $eventName), $params);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user