Event Class
The event class allows you to interact with the Fuel Core without having to alter any core files.
register($event, $callback)
The register method allows files to register an object that will be run when the trigger method is called.
| Static |
Yes |
| Parameters |
| Param |
Default |
Description |
| $event |
required |
The event you are registering your code to. |
| $callback |
required |
The callback method. |
|
| Returns |
boolean |
| Example |
Event::register('user_login', 'Class::method')
|
trigger($event, $data = '', $return_type = 'string')
The trigger method is used to trigger or activate callbacks that are associated through the register method.
| Static |
Yes |
| Parameters |
| Param |
Default |
Description |
| $event |
required |
The event you are triggering. |
| $data |
''
|
Any data you want to send to the method registered. |
| $return_type |
'string'
|
What type of return data you expect. (string, array, json, none, serialized) - Default is string |
|
| Returns |
mixed - Dependent on the $return_type. |
| Example |
Event::trigger('user_login', $data)
|
has_events($event)
The has_events method is available so you can check if a particular registered event has triggers.
| Static |
Yes |
| Parameters |
| Param |
Default |
Description |
| $event |
required |
The event you are checking. |
|
| Returns |
boolean |
| Example |
Event::has_events('user_login')
|