summaryrefslogtreecommitdiffstats
path: root/system/core/Common.php
diff options
context:
space:
mode:
authorAndrey Andreev <narf@devilix.net>2014-02-24 10:31:36 +0100
committerAndrey Andreev <narf@devilix.net>2014-02-24 10:31:36 +0100
commitc26b9ebb00e29be2e972fece3bcf73d33249a64b (patch)
treeb10dac6db61cc657bf5c906a8495994f935c102f /system/core/Common.php
parent82179bf31f00564282f2a4d9873c6107b6732631 (diff)
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.
Diffstat (limited to 'system/core/Common.php')
-rw-r--r--system/core/Common.php11
1 files changed, 6 insertions, 5 deletions
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();
}
}