Skip to content

Commit

Permalink
Clean Up
Browse files Browse the repository at this point in the history
  • Loading branch information
Nathan Macnamara committed Jun 1, 2014
1 parent 17a105d commit d44d9eb
Showing 1 changed file with 26 additions and 31 deletions.
57 changes: 26 additions & 31 deletions core/MY_Loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down

0 comments on commit d44d9eb

Please sign in to comment.