Class Events

Summary

Fully Qualified Name: CodeIgniter\Events\Events

Description

Events

Methods

Name Description Defined By
getFiles() Returns the files that were found/loaded during this request. Events
getPerformanceLogs() Getter for the performance log records. Events
initialize() Ensures that we have a events file ready. Events
listeners() Returns an array of listeners for a single event. They are sorted by priority. Events
on() Registers an action to happen on an event. The action can be any sort of callable: Events
removeAllListeners() Removes all listeners. Events
removeListener() Removes a single listener from an event. Events
setFiles() Sets the path to the file that routes are read from. Events
simulate() Turns simulation on or off. When on, events will not be triggered, simply logged. Useful during testing when you don't actually want the tests to run. Events
trigger() Runs through all subscribed methods running them one at a time, until either: a) All subscribers have finished or b) a method returns false, at which point execution of subscribers stops. Events

Method Details

getFiles()

Returns the files that were found/loaded during this request.

Returns: mixed

getPerformanceLogs()

Getter for the performance log records.

Returns: array

initialize()

Ensures that we have a events file ready.

Returns:

listeners()

Returns an array of listeners for a single event. They are sorted by priority.

If the listener could not be found, returns FALSE, or TRUE if it was removed.

Parameter Name Type Description
$event_name
$event_name

Returns: array

on()

Registers an action to happen on an event. The action can be any sort of callable:

Events::on('create', 'myFunction'); // procedural function Events::on('create', ['myClass', 'myMethod']); // Class::method Events::on('create', [$myInstance, 'myMethod']); // Method on an existing instance Events::on('create', function() }); // Closure

Parameter Name Type Description
$event_name
$callback callable
$priority int
$event_name

Returns:

removeAllListeners()

Removes all listeners.

If the event_name is specified, only listeners for that event will be removed, otherwise all listeners for all events are removed.

Parameter Name Type Description
$event_name null

Returns:

removeListener()

Removes a single listener from an event.

If the listener couldn't be found, returns FALSE, else TRUE if it was removed.

Parameter Name Type Description
$event_name
$listener callable
$event_name

Returns: bool

setFiles()

Sets the path to the file that routes are read from.

Parameter Name Type Description
$files array

Returns:

simulate()

Turns simulation on or off. When on, events will not be triggered, simply logged. Useful during testing when you don't actually want the tests to run.

Parameter Name Type Description
$choice bool

Returns:

trigger()

Runs through all subscribed methods running them one at a time, until either: a) All subscribers have finished or b) a method returns false, at which point execution of subscribers stops.

Parameter Name Type Description
$arguments
$eventName
$arguments

Returns: bool

Top