From d44d9eb9f23544c21ae7dfac3ed1b51c36575194 Mon Sep 17 00:00:00 2001 From: Nathan Macnamara Date: Sun, 1 Jun 2014 18:25:50 +0100 Subject: [PATCH] Clean Up --- core/MY_Loader.php | 57 +++++++++++++++++++++------------------------- 1 file changed, 26 insertions(+), 31 deletions(-) diff --git a/core/MY_Loader.php b/core/MY_Loader.php index 1e44b6d..9508d01 100644 --- a/core/MY_Loader.php +++ b/core/MY_Loader.php @@ -14,47 +14,42 @@ public function __construct() { } /** Load a events module * */ - public function event($event = '', $params = NULL, $object_name = NULL) { - + public function event($event = '', $params = NULL, $object_name = NULL) + { if (is_array($event)) - return $this->libraries($event); - - $class = strtolower(basename($event)); - - if (isset($this->_ci_classes[$class]) AND $_alias = $this->_ci_classes[$class]) - return CI::$APP->$_alias; - - ($_alias = strtolower($object_name)) OR $_alias = $class; - - list($path, $_event) = Modules::find($event, $this->_module, 'events/'); + { + foreach ($event as $class) + { + $this->library($class, $params); + } - /* load library config file as params */ - if ($params == NULL) { - list($path2, $file) = Modules::find($_alias, $this->_module, 'config/'); - ($path2) AND $params = Modules::load_file($file, $path2, 'config'); + return; } - if ($path === FALSE) { - - $this->_ci_events_class($event, $params, $object_name); - $_alias = $this->_ci_classes[$class]; - } else { - - Modules::load_file($_event, $path); - - $event = ucfirst($_event); - CI::$APP->$_alias = new $event($params); + if ($event == '' OR isset($this->_base_classes[$event])) + { + return FALSE; + } - $this->_ci_classes[$class] = $_alias; + if ( ! is_null($params) && ! is_array($params)) + { + $params = NULL; } - return CI::$APP->$_alias; + $this->_ci_events_class($event, $params, $object_name); } /** Load an array of events * */ - public function events($events) { - foreach ($events as $_event) - $this->event($_event); + public function events($event = '', $params = NULL, $object_name = NULL) + { + if (is_array($event)) + { + foreach ($event as $class) + { + $this->library($class, $params); + } + } + return; } /**