Fires code events and executes event listener callbacks.

package XenForo_CodeEvents

 Methods

Adds a listener for the specified event.

addListener(string $event, callback $callback) 

This method takes an arbitrary callback, so can be used with more advanced things like object-based callbacks (and simple function-only callbacks).

Parameters

$event

string

Event to listen to

$callback

callback

Function/method to call.

Fires the specified code event and calls any listener callbacks that are attached to it.

fire(string $event, array $args) : boolean

The listener may return false, which will prevent any further listeners from running and cause this function (fire) to return false. This indicates that the listener handled the job the built-in code was going to do and if applicable, the built-in code need not run. (This will only apply in limited circumstances.)

Note that if you want to allow arguments to be modified, they must be passed by reference. Eg: array($value, &$reference) If you do this, the receiving function will always be given the arguments by reference!

Parameters

$event

string

Name of the event to first

$args

array

List of arguments to pass to the callback. If you want to make something modifiable, you must pass it by reference to the array.

Returns

boolean

Gets the listeners for a specific event.

getEventListeners(string $event) : array | false

Parameters

$event

string

Returns

arrayfalseList of listener callbacks or false

Removes all listeners.

removeListeners() 

Sets the list of listeners for all events.

setListeners(array $listeners, boolean $keepExisting) 

Parameters

$listeners

array

Format: [event id][] => callback

$keepExisting

boolean

Private constructor, use statically.

__construct() 

 Properties

 

The list of event listeners for all events.

$_listeners : array