diff options
| author | 2015-07-27 16:25:34 +0200 | |
|---|---|---|
| committer | 2015-07-27 16:25:34 +0200 | |
| commit | ee093c611cb8e466b02e74431b0a9f2b43adada5 (patch) | |
| tree | 9fd7b1a5c081308b39b8cc29a368410a53d46425 /lib/Minz/Configuration.php | |
| parent | f3fc6f02bec36463e6a021bf41d498e32d956362 (diff) | |
| parent | c1a44a8761778da81bde608f6d20f5decdd8b9b6 (diff) | |
Merge pull request #926 from marienfressinaud/923-load-array-config
Load configuration by recursion
Diffstat (limited to 'lib/Minz/Configuration.php')
| -rw-r--r-- | lib/Minz/Configuration.php | 26 |
1 files changed, 10 insertions, 16 deletions
diff --git a/lib/Minz/Configuration.php b/lib/Minz/Configuration.php index ab5bb4fc2..1db8e2daf 100644 --- a/lib/Minz/Configuration.php +++ b/lib/Minz/Configuration.php @@ -85,11 +85,6 @@ class Minz_Configuration { private $data = array(); /** - * The default values, an empty array by default. - */ - private $data_default = array(); - - /** * An object which help to set good values in configuration. */ private $configuration_setter = null; @@ -119,21 +114,22 @@ class Minz_Configuration { $configuration_setter = null) { $this->namespace = $namespace; $this->config_filename = $config_filename; + $this->default_filename = $default_filename; + $this->_configurationSetter($configuration_setter); + + if (!is_null($this->default_filename)) { + $this->data = self::load($this->default_filename); + } try { - $this->data = self::load($this->config_filename); + $this->data = array_replace_recursive( + $this->data, self::load($this->config_filename) + ); } catch (Minz_FileNotExistException $e) { - if (is_null($default_filename)) { + if (is_null($this->default_filename)) { throw $e; } } - - $this->default_filename = $default_filename; - if (!is_null($this->default_filename)) { - $this->data_default = self::load($this->default_filename); - } - - $this->_configurationSetter($configuration_setter); } /** @@ -160,8 +156,6 @@ class Minz_Configuration { return $this->data[$key]; } elseif (!is_null($default)) { return $default; - } elseif (isset($this->data_default[$key])) { - return $this->data_default[$key]; } else { Minz_Log::warning($key . ' does not exist in configuration'); return null; |
