Don't use globals
- Use load_class() to get objects during bootstrap process.
- Change load_class() to accept a class constructor parameter
instead of previously unused class name prefix.
- Change CI_Router::__construct() to accept as a parameter.
diff --git a/system/core/Common.php b/system/core/Common.php
index 0ea53c4..24315a0 100644
--- a/system/core/Common.php
+++ b/system/core/Common.php
@@ -130,7 +130,7 @@
* @param string the class name prefix
* @return object
*/
- function &load_class($class, $directory = 'libraries', $prefix = 'CI_')
+ function &load_class($class, $directory = 'libraries', $param = NULL)
{
static $_classes = array();
@@ -148,7 +148,7 @@
{
if (file_exists($path.$directory.'/'.$class.'.php'))
{
- $name = $prefix.$class;
+ $name = 'CI_'.$class;
if (class_exists($name, FALSE) === FALSE)
{
@@ -166,7 +166,7 @@
if (class_exists($name, FALSE) === FALSE)
{
- require_once(APPPATH.$directory.'/'.config_item('subclass_prefix').$class.'.php');
+ require_once(APPPATH.$directory.'/'.$name.'.php');
}
}
@@ -183,8 +183,9 @@
// Keep track of what we just loaded
is_loaded($class);
- $_classes[$class] = new $name();
- return $_classes[$class];
+ return $_classes[$class] = isset($param)
+ ? new $name($param)
+ : new $name();
}
}