From fc871032057c5a9003ed8ef06ac47ef40cf90969 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Tue, 2 Aug 2011 10:43:12 -0500 Subject: [PATCH] Refactoring configuration class. --- system/config.php | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/system/config.php b/system/config.php index e1727da9..cce28dce 100644 --- a/system/config.php +++ b/system/config.php @@ -45,9 +45,7 @@ class Config { list($file, $key) = static::parse($key); - static::load($file); - - if ( ! array_key_exists($file, static::$items)) + if ( ! static::load($file)) { return is_callable($default) ? call_user_func($default) : $default; } @@ -99,11 +97,11 @@ class Config { * Any environment specific configuration files will be merged with the root file. * * @param string $file - * @return void + * @return bool */ public static function load($file) { - if (array_key_exists($file, static::$items)) return; + if (array_key_exists($file, static::$items)) return true; $config = (file_exists($path = CONFIG_PATH.$file.EXT)) ? require $path : array(); @@ -112,10 +110,7 @@ class Config { $config = array_merge($config, require $path); } - if (count($config) > 0) - { - static::$items[$file] = $config; - } + return (count(static::$items[$file] = $config) > 0); } } \ No newline at end of file