mirror of
https://github.com/php/php-src.git
synced 2025-08-18 15:08:55 +02:00
* added optional layer parameter to get() method
* added isDefinedLayer() method
This commit is contained in:
parent
9a6296c47e
commit
c55f61c9aa
1 changed files with 26 additions and 5 deletions
|
@ -446,7 +446,7 @@ class PEAR_Config extends PEAR
|
||||||
}
|
}
|
||||||
|
|
||||||
// }}}
|
// }}}
|
||||||
// {{{ get(key)
|
// {{{ get(key, [layer])
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a configuration value, prioritizing layers as per the
|
* Returns a configuration value, prioritizing layers as per the
|
||||||
|
@ -458,12 +458,16 @@ class PEAR_Config extends PEAR
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function get($key)
|
function get($key, $layer = null)
|
||||||
{
|
{
|
||||||
foreach ($this->layers as $layer) {
|
if ($layer === null) {
|
||||||
if (isset($this->configuration[$layer][$key])) {
|
foreach ($this->layers as $layer) {
|
||||||
return $this->configuration[$layer][$key];
|
if (isset($this->configuration[$layer][$key])) {
|
||||||
|
return $this->configuration[$layer][$key];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
} elseif (isset($this->configuration[$layer][$key])) {
|
||||||
|
return $this->configuration[$layer][$key];
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -716,6 +720,23 @@ class PEAR_Config extends PEAR
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// }}}
|
||||||
|
// {{{ isDefinedLayer(key)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tells whether a given config layer exists.
|
||||||
|
*
|
||||||
|
* @param string config layer
|
||||||
|
*
|
||||||
|
* @return bool whether <config layer> exists in this object
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
*/
|
||||||
|
function isDefinedLayer($layer)
|
||||||
|
{
|
||||||
|
return isset($this->configuration[$layer]);
|
||||||
|
}
|
||||||
|
|
||||||
// }}}
|
// }}}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue