Skip to content

Commit 5e16ec6

Browse files
committed
Added ability to auto load package config files. Fixes bcit-ci#281
1 parent 6113f54 commit 5e16ec6

File tree

1 file changed

+21
-8
lines changed

1 file changed

+21
-8
lines changed

system/core/Loader.php

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -870,15 +870,28 @@ function _ci_init_class($class, $prefix = '', $config = FALSE, $object_name = NU
870870
// Is there an associated config file for this class? Note: these should always be lowercase
871871
if ($config === NULL)
872872
{
873-
// We test for both uppercase and lowercase, for servers that
874-
// are case-sensitive with regard to file names
875-
if (file_exists(APPPATH.'config/'.strtolower($class).EXT))
876-
{
877-
include_once(APPPATH.'config/'.strtolower($class).EXT);
878-
}
879-
elseif (file_exists(APPPATH.'config/'.ucfirst(strtolower($class)).EXT))
873+
// Fetch the config paths containing any package paths
874+
$config_component = $this->_ci_get_component('config');
875+
876+
if (is_array($config_component->_config_paths))
880877
{
881-
include_once(APPPATH.'config/'.ucfirst(strtolower($class)).EXT);
878+
// Break on the first found file, thus package files
879+
// are not overridden by default paths
880+
foreach ($config_component->_config_paths as $path)
881+
{
882+
// We test for both uppercase and lowercase, for servers that
883+
// are case-sensitive with regard to file names
884+
if (file_exists($path .'config/'.strtolower($class).EXT))
885+
{
886+
include_once($path .'config/'.strtolower($class).EXT);
887+
break;
888+
}
889+
elseif (file_exists($path .'config/'.ucfirst(strtolower($class)).EXT))
890+
{
891+
include_once($path .'config/'.ucfirst(strtolower($class)).EXT);
892+
break;
893+
}
894+
}
882895
}
883896
}
884897

0 commit comments

Comments
 (0)