Add $default param to getConfig() method
- Pico::getConfig() - AbstractPicoPlugin::getPluginCongif()
This commit is contained in:
parent
8138212a27
commit
32ae70f398
@ -150,22 +150,23 @@ abstract class AbstractPicoPlugin implements PicoPluginInterface
|
|||||||
* the config array
|
* the config array
|
||||||
*
|
*
|
||||||
* @param string $configName optional name of a config variable
|
* @param string $configName optional name of a config variable
|
||||||
* @return mixed returns either the value of the named plugin
|
* @param mixed $default optional default value to return when the
|
||||||
* config variable, null if the config variable doesn't exist or the
|
* named config variable doesn't exist
|
||||||
* plugin's config array if no config name was supplied
|
* @return mixed if no name of a config variable has been
|
||||||
|
* supplied, the plugin's config array is returned; otherwise it
|
||||||
|
* returns either the value of the named config variable, or, if the
|
||||||
|
* named config variable doesn't exist, the provided default value
|
||||||
|
* or NULL
|
||||||
*/
|
*/
|
||||||
public function getPluginConfig($configName = null)
|
public function getPluginConfig($configName = null, $default = null)
|
||||||
{
|
{
|
||||||
$pluginConfig = $this->getConfig(get_called_class());
|
$pluginConfig = $this->getConfig(get_called_class(), array());
|
||||||
if ($pluginConfig) {
|
|
||||||
if ($configName === null) {
|
if ($configName === null) {
|
||||||
return $pluginConfig;
|
return $pluginConfig;
|
||||||
} elseif (isset($pluginConfig[$configName])) {
|
|
||||||
return $pluginConfig[$configName];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return isset($pluginConfig[$configName]) ? $pluginConfig[$configName] : $default;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
13
lib/Pico.php
13
lib/Pico.php
@ -901,14 +901,17 @@ class Pico
|
|||||||
* @see Pico::setConfig()
|
* @see Pico::setConfig()
|
||||||
* @see Pico::loadConfig()
|
* @see Pico::loadConfig()
|
||||||
* @param string $configName optional name of a config variable
|
* @param string $configName optional name of a config variable
|
||||||
* @return mixed returns either the value of the named config
|
* @param mixed $default optional default value to return when the
|
||||||
* variable, null if the config variable doesn't exist or the config
|
* named config variable doesn't exist
|
||||||
* array if no config name was supplied
|
* @return mixed if no name of a config variable has been
|
||||||
|
* supplied, the config array is returned; otherwise it returns either
|
||||||
|
* the value of the named config variable, or, if the named config
|
||||||
|
* variable doesn't exist, the provided default value or NULL
|
||||||
*/
|
*/
|
||||||
public function getConfig($configName = null)
|
public function getConfig($configName = null, $default = null)
|
||||||
{
|
{
|
||||||
if ($configName !== null) {
|
if ($configName !== null) {
|
||||||
return isset($this->config[$configName]) ? $this->config[$configName] : null;
|
return isset($this->config[$configName]) ? $this->config[$configName] : $default;
|
||||||
} else {
|
} else {
|
||||||
return $this->config;
|
return $this->config;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user