config : allow to have the defaults params in ->get() in case of array without defined key
git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@2648 bf3deb0d-5f1a-0410-827f-c0cc1f45334c
This commit is contained in:
16
config.php
16
config.php
@@ -99,6 +99,22 @@ class config
|
||||
if (! isset ($conf[$param][$key]))
|
||||
$conf[$param][$key] = $val;
|
||||
}
|
||||
foreach ($conf[$param] as $key=>$val)
|
||||
{
|
||||
if ($key === "not configured")
|
||||
continue;
|
||||
if (is_array ($val))
|
||||
{
|
||||
if (! isset ($this->default[$param]["not configured"]))
|
||||
throw new \Exception ("Invalid config provided : array provided ".
|
||||
"without default values", 500);
|
||||
foreach ($this->default[$param]["not configured"] as $k=>$v)
|
||||
{
|
||||
if (! array_key_exists ($k, $conf[$param][$key]))
|
||||
$conf[$param][$key][$k] = $v;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (count ($conf[$param]) > 1 && isset ($conf[$param]["not configured"]))
|
||||
unset ($conf[$param]["not configured"]);
|
||||
return $conf[$param];
|
||||
|
||||
Reference in New Issue
Block a user