config : if the parameter is an array, check if all the keys are defined or use the default one

git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@2097 bf3deb0d-5f1a-0410-827f-c0cc1f45334c
This commit is contained in:
2015-04-29 10:53:03 +00:00
parent 7c306e27ea
commit d64f1f035e

View File

@@ -66,7 +66,18 @@ class config
if ($rc !== 1)
throw new Exception ("Error in configuration file");
if (array_key_exists ($param, $conf))
{
if (! is_array ($conf[$param]))
return $conf[$param];
// if the configuration is an array, check if all the keys are defined
// or use the default
foreach ($this->default[$param] as $key=>$val)
{
if (! isset ($conf[$param][$key]))
$conf[$param][$key] = $val;
}
return $conf[$param];
}
return $this->default[$param];
}