The updated autoload() method is included below. It uses the loader's _ci_model_paths property to locate models. I suspect this is intended to be a private property, and may not work in future versions, but we'll cross that bridge when we get to it.
Code:
public static function autoload($class)
{
// Don't attempt to autoload CI_ or MY_ prefixed classes
if (in_array(substr($class, 0, 3), array('CI_', 'EE_', 'MY_')))
{
return;
}
// Prepare class
$class = strtolower($class);
// Prepare path
$CI =& get_instance();
if (isset($CI->load->_ci_model_paths) && is_array($CI->load->_ci_model_paths))
{
// use CI loader's model path
$paths = $CI->load->_ci_model_paths;
}
else
{
$paths = array(APPPATH);
}
// Check if file exists, require_once if it does
if (file_exists($file))
{
require_once($file);
break;
}
}
// if class not loaded, do a recursive search of APPPATH for the class
if (! class_exists($class))
{
DataMapper::recursive_require_once($class, APPPATH . 'models');
}
}