From d64f1f035e73b24bcd95bec5f4c2467ea21b8746 Mon Sep 17 00:00:00 2001 From: Dominique Fournier Date: Wed, 29 Apr 2015 10:53:03 +0000 Subject: [PATCH] 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 --- config.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/config.php b/config.php index 3624d71..108d0b2 100644 --- a/config.php +++ b/config.php @@ -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]; }