FileAccess Orion

EventManagerInterface extends SharedEventsCapableInterface

Interface for messengers

Table of Contents

addIdentifiers()  : void
Add identifier(s) (appends to any currently set identifiers)
attach()  : callable
Attach a listener to an event
clearListeners()  : void
Clear all listeners for a given event
detach()  : void
Detach a listener.
getIdentifiers()  : array<string|int, mixed>
Get the identifier(s) for this EventManager
getSharedManager()  : null|SharedEventManagerInterface
Retrieve the shared event manager, if composed.
setEventPrototype()  : void
Provide an event prototype to use with trigger().
setIdentifiers()  : void
Set the identifiers (overrides any currently set identifiers)
trigger()  : ResponseCollection
Create and trigger an event.
triggerEvent()  : ResponseCollection
Trigger an event
triggerEventUntil()  : ResponseCollection
Trigger an event, applying a callback to each listener result.
triggerUntil()  : ResponseCollection
Create and trigger an event, applying a callback to each listener result.

Methods

addIdentifiers()

Add identifier(s) (appends to any currently set identifiers)

public addIdentifiers(array<string|int, string> $identifiers) : void
Parameters
$identifiers : array<string|int, string>
Return values
void

attach()

Attach a listener to an event

public attach(string $eventName, callable $listener[, int $priority = 1 ]) : callable

The first argument is the event, and the next argument is a callable that will respond to that event.

The last argument indicates a priority at which the event should be executed; by default, this value is 1; however, you may set it for any integer value. Higher values have higher priority (i.e., execute first).

You can specify "*" for the event name. In such cases, the listener will be triggered for every event that has registered listeners at the time it is attached. As such, register wildcard events last whenever possible!

Parameters
$eventName : string

Event to which to listen.

$listener : callable
$priority : int = 1

Priority at which to register listener.

Return values
callable

clearListeners()

Clear all listeners for a given event

public clearListeners(string $eventName) : void
Parameters
$eventName : string
Return values
void

detach()

Detach a listener.

public detach(callable $listener[, null|string $eventName = null ]) : void

If no $event or '*' is provided, detaches listener from all events; otherwise, detaches only from the named event.

Parameters
$listener : callable
$eventName : null|string = null

Event from which to detach; null and '*' indicate all events.

Return values
void

getIdentifiers()

Get the identifier(s) for this EventManager

public getIdentifiers() : array<string|int, mixed>
Return values
array<string|int, mixed>

setEventPrototype()

Provide an event prototype to use with trigger().

public setEventPrototype(EventInterface $prototype) : void

When trigger() needs to create an event instance, it should clone the prototype provided to this method.

Parameters
$prototype : EventInterface
Return values
void

setIdentifiers()

Set the identifiers (overrides any currently set identifiers)

public setIdentifiers(array<string|int, string> $identifiers) : void
Parameters
$identifiers : array<string|int, string>
Return values
void

trigger()

Create and trigger an event.

public trigger(string $eventName[, null|object|string $target = null ][, array<string|int, mixed>|object $argv = [] ]) : ResponseCollection

Use this method when you do not want to create an EventInterface instance prior to triggering. You will be required to pass:

  • the event name
  • the event target (can be null)
  • any event parameters you want to provide (empty array by default)

It will create the Event instance for you and then trigger all listeners related to the event.

Parameters
$eventName : string
$target : null|object|string = null
$argv : array<string|int, mixed>|object = []
Return values
ResponseCollection

triggerEventUntil()

Trigger an event, applying a callback to each listener result.

public triggerEventUntil(callable $callback, EventInterface $event) : ResponseCollection

Provided an EventInterface instance, this method will trigger listeners based on the event name, raising an exception if the event name is missing.

The result of each listener is passed to $callback; if $callback returns a boolean true value, the manager must short-circuit listener execution.

Parameters
$callback : callable
$event : EventInterface
Return values
ResponseCollection

triggerUntil()

Create and trigger an event, applying a callback to each listener result.

public triggerUntil(callable $callback, string $eventName[, null|object|string $target = null ][, array<string|int, mixed>|object $argv = [] ]) : ResponseCollection

Use this method when you do not want to create an EventInterface instance prior to triggering. You will be required to pass:

  • the event name
  • the event target (can be null)
  • any event parameters you want to provide (empty array by default)

It will create the Event instance for you, and trigger all listeners related to the event.

The result of each listener is passed to $callback; if $callback returns a boolean true value, the manager must short-circuit listener execution.

Parameters
$callback : callable
$eventName : string
$target : null|object|string = null
$argv : array<string|int, mixed>|object = []
Return values
ResponseCollection

Search results