Permalink
Browse files

Better way - autoloader uses first config path

Signed-off-by: dchill42 <dchill42@gmail.com>
  • Loading branch information...
1 parent 60d100f commit eeb6a480a4a25b7fe96e9ba0cf3aef273fd13c67 @dchill42 committed Aug 30, 2012
Showing with 6 additions and 13 deletions.
  1. +6 −12 system/core/Loader.php
  2. +0 −1 tests/mocks/core/loader.php
View
@@ -75,14 +75,6 @@ class CI_Loader {
protected $_ci_helper_paths = array();
/**
- * Path to autoloader config file
- * This lets us override it in unit testing
- *
- * @var string
- */
- protected $_ci_autoloader_path = APPPATH;
-
- /**
* List of loaded base classes
*
* @var array
@@ -1148,13 +1140,16 @@ protected function _ci_init_class($class, $prefix = '', $config = FALSE, $object
*/
protected function _ci_autoloader()
{
- if (defined('ENVIRONMENT') && file_exists($this->_ci_autoloader_path.'config/'.ENVIRONMENT.'/autoload.php'))
+ // Get autoloader file from config path
+ $CI =& get_instance();
+ $path = reset($CI->config->_config_paths).'config/';
+ if (defined('ENVIRONMENT') && file_exists($path.ENVIRONMENT.'/autoload.php'))
{
- include($this->_ci_autoloader_path.'config/'.ENVIRONMENT.'/autoload.php');
+ include($path.ENVIRONMENT.'/autoload.php');
}
else
{
- include($this->_ci_autoloader_path.'config/autoload.php');
+ include($path.'autoload.php');
}
if ( ! isset($autoload))
@@ -1174,7 +1169,6 @@ protected function _ci_autoloader()
// Load any custom config file
if (count($autoload['config']) > 0)
{
- $CI =& get_instance();
foreach ($autoload['config'] as $key => $val)
{
$CI->config->load($val);
@@ -30,7 +30,6 @@ public function __construct()
$this->_ci_helper_paths = array($this->app_path, $this->base_path);
$this->_ci_model_paths = array($this->app_path);
$this->_ci_view_paths = array($this->app_path.'views/' => TRUE);
- $this->_ci_autoloader_path = $this->app_path;
}
/**

0 comments on commit eeb6a48

Please sign in to comment.