Add AbstractPicoPlugin::getPluginConfig() method
This commit is contained in:
parent
a3fa373119
commit
1709b920d1
@ -74,9 +74,9 @@ abstract class AbstractPicoPlugin implements PicoPluginInterface
|
|||||||
if ($pluginEnabled !== null) {
|
if ($pluginEnabled !== null) {
|
||||||
$this->setEnabled($pluginEnabled);
|
$this->setEnabled($pluginEnabled);
|
||||||
} else {
|
} else {
|
||||||
$pluginConfig = $this->getConfig(get_called_class());
|
$pluginEnabled = $this->getPluginConfig('enabled');
|
||||||
if (is_array($pluginConfig) && isset($pluginConfig['enabled'])) {
|
if ($pluginEnabled !== null) {
|
||||||
$this->setEnabled($pluginConfig['enabled']);
|
$this->setEnabled($pluginEnabled);
|
||||||
} elseif ($this->enabled) {
|
} elseif ($this->enabled) {
|
||||||
// make sure dependencies are already fulfilled,
|
// make sure dependencies are already fulfilled,
|
||||||
// otherwise the plugin needs to be enabled manually
|
// otherwise the plugin needs to be enabled manually
|
||||||
@ -135,6 +135,29 @@ abstract class AbstractPicoPlugin implements PicoPluginInterface
|
|||||||
return $this->pico;
|
return $this->pico;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns either the value of the specified plugin config variable or
|
||||||
|
* the config array
|
||||||
|
*
|
||||||
|
* @param string $configName optional name of a config variable
|
||||||
|
* @return mixed returns either the value of the named plugin
|
||||||
|
* config variable, null if the config variable doesn't exist or the
|
||||||
|
* plugin's config array if no config name was supplied
|
||||||
|
*/
|
||||||
|
protected function getPluginConfig($configName = null)
|
||||||
|
{
|
||||||
|
$pluginConfig = $this->getConfig(get_called_class());
|
||||||
|
if ($pluginConfig) {
|
||||||
|
if ($configName === null) {
|
||||||
|
return $pluginConfig;
|
||||||
|
} elseif (isset($pluginConfig[$configName])) {
|
||||||
|
return $pluginConfig[$configName];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Passes all not satisfiable method calls to Pico
|
* Passes all not satisfiable method calls to Pico
|
||||||
*
|
*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user