From c26b9ebb00e29be2e972fece3bcf73d33249a64b Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 24 Feb 2014 11:31:36 +0200 Subject: 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. --- system/core/Common.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'system/core/Common.php') diff --git a/system/core/Common.php b/system/core/Common.php index 0ea53c4e2..24315a054 100644 --- a/system/core/Common.php +++ b/system/core/Common.php @@ -130,7 +130,7 @@ if ( ! function_exists('load_class')) * @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 ( ! function_exists('load_class')) { if (file_exists($path.$directory.'/'.$class.'.php')) { - $name = $prefix.$class; + $name = 'CI_'.$class; if (class_exists($name, FALSE) === FALSE) { @@ -166,7 +166,7 @@ if ( ! function_exists('load_class')) 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 @@ if ( ! function_exists('load_class')) // 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(); } } -- cgit v1.2.3-24-g4f1b