Added Config->getNested(key) and Config->setNested(key, value)

This commit is contained in:
Shoghi Cervantes
2014-12-07 16:41:43 +01:00
parent 747f7685e7
commit 964bf98ca6
2 changed files with 44 additions and 17 deletions

View File

@@ -1224,24 +1224,9 @@ class Server{
* @return mixed
*/
public function getProperty($variable, $defaultValue = null){
$vars = explode(".", $variable);
$base = array_shift($vars);
if($this->config->exists($base)){
$base = $this->config->get($base);
}else{
return $defaultValue;
}
$value = $this->config->getNested($variable);
while(count($vars) > 0){
$baseKey = array_shift($vars);
if(is_array($base) and isset($base[$baseKey])){
$base = $base[$baseKey];
}else{
return $defaultValue;
}
}
return $base;
return $value === null ? $defaultValue : $value;
}
/**