Version 1.0
- Author: Dan Horrigan
Based off (unreleased) code by Eric Barnes (with his permission of course).
Events is a simple events library for CodeIgniter (all versions)
1. Copy Events.php to your application/libraries folder.
2. Load it like normal: $this->load->library('events');
(or autoload it).
All Events functions are static.
You can add a listener to an event with the register() function:
Events::register('event_name_here', array('class_name_or_object_ref', 'method_name'));
The second parameter of register() is an array that is callable via call_user_func.
You trigger an Event by calling the trigger() function:
$event_return = Events::trigger('event_name_here', $data, 'string');
The 3rd parameter is the type of data you wish trigger() to return. Your options are as follows:
- ‘array’
- ‘json’
- ‘serialized’
- ‘string’ (the default)