Commit c13b54da1de36c1db6cdb9d380867094c580c997
1 parent
89ecf44a
add local config
Showing
2 changed files
with
30 additions
and
1 deletions
Show diff stats
.gitignore
src/lib/config.php
@@ -32,7 +32,10 @@ namespace | @@ -32,7 +32,10 @@ namespace | ||
32 | */ | 32 | */ |
33 | public function __construct() | 33 | public function __construct() |
34 | { | 34 | { |
35 | - $this->config = require( ROOT_PATH.'config/global.php' ); | 35 | + $this->config = self::merge( |
36 | + require( ROOT_PATH.'config/global.php' ), | ||
37 | + require( ROOT_PATH.'config/global-local.php' ) | ||
38 | + ); | ||
36 | } | 39 | } |
37 | 40 | ||
38 | /////////////////////////////////////////////////////////////////////// | 41 | /////////////////////////////////////////////////////////////////////// |
@@ -270,6 +273,31 @@ namespace | @@ -270,6 +273,31 @@ namespace | ||
270 | { | 273 | { |
271 | return ROOT_PATH.'log/'; | 274 | return ROOT_PATH.'log/'; |
272 | } | 275 | } |
276 | + | ||
277 | + | ||
278 | + public static function merge($a, $b) | ||
279 | + { | ||
280 | + $args = func_get_args(); | ||
281 | + $res = array_shift($args); | ||
282 | + while (!empty($args)) { | ||
283 | + $next = array_shift($args); | ||
284 | + foreach ($next as $k => $v) { | ||
285 | + if (is_int($k)) { | ||
286 | + if (isset($res[$k])) { | ||
287 | + $res[] = $v; | ||
288 | + } else { | ||
289 | + $res[$k] = $v; | ||
290 | + } | ||
291 | + } elseif (is_array($v) && isset($res[$k]) && is_array($res[$k])) { | ||
292 | + $res[$k] = self::merge($res[$k], $v); | ||
293 | + } else { | ||
294 | + $res[$k] = $v; | ||
295 | + } | ||
296 | + } | ||
297 | + } | ||
298 | + | ||
299 | + return $res; | ||
300 | + } | ||
273 | 301 | ||
274 | /////////////////////////////////////////////////////////////////////// | 302 | /////////////////////////////////////////////////////////////////////// |
275 | } | 303 | } |