diff options
author | Eric Barnes <eric@ericlbarnes.com> | 2011-01-04 23:25:23 +0100 |
---|---|---|
committer | Eric Barnes <eric@ericlbarnes.com> | 2011-01-04 23:25:23 +0100 |
commit | 5e16ec6b33ed6a80bf511b2bf6eb4fc5a1103c94 (patch) | |
tree | 5a67676c6ff5a86b1c7c0c3eb1f6e2b7a837a0c6 | |
parent | 6113f5462c5801964b12a95e62922606aa258808 (diff) |
Added ability to auto load package config files. Fixes #281
-rw-r--r-- | system/core/Loader.php | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/system/core/Loader.php b/system/core/Loader.php index 136cae9bf..225b43912 100644 --- a/system/core/Loader.php +++ b/system/core/Loader.php @@ -870,15 +870,28 @@ class CI_Loader { // Is there an associated config file for this class? Note: these should always be lowercase if ($config === NULL) { - // We test for both uppercase and lowercase, for servers that - // are case-sensitive with regard to file names - if (file_exists(APPPATH.'config/'.strtolower($class).EXT)) - { - include_once(APPPATH.'config/'.strtolower($class).EXT); - } - elseif (file_exists(APPPATH.'config/'.ucfirst(strtolower($class)).EXT)) + // Fetch the config paths containing any package paths + $config_component = $this->_ci_get_component('config'); + + if (is_array($config_component->_config_paths)) { - include_once(APPPATH.'config/'.ucfirst(strtolower($class)).EXT); + // Break on the first found file, thus package files + // are not overridden by default paths + foreach ($config_component->_config_paths as $path) + { + // We test for both uppercase and lowercase, for servers that + // are case-sensitive with regard to file names + if (file_exists($path .'config/'.strtolower($class).EXT)) + { + include_once($path .'config/'.strtolower($class).EXT); + break; + } + elseif (file_exists($path .'config/'.ucfirst(strtolower($class)).EXT)) + { + include_once($path .'config/'.ucfirst(strtolower($class)).EXT); + break; + } + } } } |