Created
September 13, 2016 15:33
-
-
Save carlosocarvalho/4aaa0f7476c60ce2ec8f9c9ddfeb9fcf to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class RegisterEventAutoload{ | |
/** | |
* [handler on start classe events | |
* @return [type] [description] | |
*/ | |
public function handler(){ | |
$ci = get_instance(); | |
$ci->load->config('register_events', true); | |
$registered = config_item('register_events'); | |
if(! $registered) return; | |
$this->registerAllEvents($registered); | |
} | |
/** | |
* [registerAllEvents description] | |
* @param [type] $events [description] | |
* @return [type] [description] | |
*/ | |
private function registerAllEvents($events){ | |
foreach ($events as $key => $ev) { | |
foreach ($ev as $classEvent) { | |
if(!is_object($classEvent)) | |
$classEvent = new $classEvent(); | |
Events::register($key , [$classEvent , 'handler']); | |
} | |
} | |
} | |
} | |
//** hooks/RegisterEventAutoload.php |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment