Blesta Source Documentation

Listener extends AbstractListener

Event Handler

Stores callbacks for particular events that may be executed when the event is triggered. Events are static, so each instance may register events triggered in this or other instances of the Event handler.

Table of Contents

Methods

getRegistered() Returns all registered listeners for the given event name
register() Register a listener, to be notified when the event is triggered. Only permits one registered event per callback.
trigger() Notifies all registered listeners of the event (called in the order they were set).
triggerUntil() Notifies all registered listeners of the event (called in the order they were set), until one returns true, then ceases notifying all remaining listeners.
unregister() Unregisters a listener if the event has been registered. Will remove all copies of the registered event in the case that it was registered multiple times.
getCallback() Creates a default callback from the given event name
Methods

getRegistered()

Returns all registered listeners for the given event name

public getRegistered(string $name) : array<string|int, mixed>
Parameters
$name : string

The name of the event to fetch registered callbacks for

Return values
array<string|int, mixed>

An array of registered callbacks

register()

Register a listener, to be notified when the event is triggered. Only permits one registered event per callback.

public register(string $name[, callable $callback = null ][, string $file = null ]) : mixed
Parameters
$name : string

The name of the event to register $callback under

$callback : callable = null

The Class/Method or Object/Method or function to execute when the event is triggered; A null callback will default to a system observer matching the given $name

$file : string = null

The full path to the file that contains the callback, null will default to looking in the \Blesta\Core\Util\Events\Observers\Class namespace (where 'Class' is the CamelCase format of the callback class [e.g. ClassName])

trigger()

Notifies all registered listeners of the event (called in the order they were set).

public trigger(EventInterface $event) : EventInterface
Parameters
$event : EventInterface

The event object to pass to the registered listeners

Return values
EventInterface

The event processed

triggerUntil()

Notifies all registered listeners of the event (called in the order they were set), until one returns true, then ceases notifying all remaining listeners.

public triggerUntil(EventInterface $event) : EventInterface
Parameters
$event : EventInterface

The event object to pass to the registered listeners

Return values
EventInterface

The event processed

unregister()

Unregisters a listener if the event has been registered. Will remove all copies of the registered event in the case that it was registered multiple times.

public unregister(string $name[, callable $callback = null ]) : mixed
Parameters
$name : string

The name of the event to unregister $callback from

$callback : callable = null

The Class/Method or Object/Method or function to unregister for the event; A null callback will default to a system observer matching the given $name

getCallback()

Creates a default callback from the given event name

private getCallback(string $name) : array<string|int, mixed>
Parameters
$name : string

The name of the event for this callback

Return values
array<string|int, mixed>

An array representing the callback

Tags
subpackage

core.Util.Events

copyright

Copyright (c) 2018, Phillips Data, Inc.

license

http://www.blesta.com/license/ The Blesta License Agreement

link

Blesta


        
On this page

Search results