Interface EventManagerInterface

Summary

Fully Qualified Name: Zend\EventManager\EventManagerInterface
Extends: SharedEventsCapableInterface

Description

Interface for messengers

Methods

Name Description Defined By
addIdentifiers() Add identifier(s) (appends to any currently set identifiers) EventManagerInterface
attach() Attach a listener to an event EventManagerInterface
clearListeners() Clear all listeners for a given event EventManagerInterface
detach() Detach a listener. EventManagerInterface
getIdentifiers() Get the identifier(s) for this EventManager EventManagerInterface
getSharedManager() Retrieve the shared event manager, if composed. SharedEventsCapableInterface
setEventPrototype() Provide an event prototype to use with trigger(). EventManagerInterface
setIdentifiers() Set the identifiers (overrides any currently set identifiers) EventManagerInterface
trigger() Create and trigger an event. EventManagerInterface
triggerEvent() Trigger an event EventManagerInterface
triggerEventUntil() Trigger an event, applying a callback to each listener result. EventManagerInterface
triggerUntil() Create and trigger an event, applying a callback to each listener result. EventManagerInterface

Method Details

addIdentifiers()

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

Parameter Name Type Description
$identifiers string[]

Returns: void

attach()

Attach a listener to an event

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!

Parameter Name Type Description
$eventName string Event
$listener callable
$priority int Priority

Returns: callable

clearListeners()

Clear all listeners for a given event

Parameter Name Type Description
$eventName string

Returns: void

detach()

Detach a listener.

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

Parameter Name Type Description
$listener callable
$eventName null|string Event

Returns: void

getIdentifiers()

Get the identifier(s) for this EventManager

Returns: array

getSharedManager()

Retrieve the shared event manager, if composed.

Returns: null|\SharedEventManagerInterface

setEventPrototype()

Provide an event prototype to use with trigger().

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

Parameter Name Type Description
$prototype \EventInterface

Returns: void

setIdentifiers()

Set the identifiers (overrides any currently set identifiers)

Parameter Name Type Description
$identifiers string[]

Returns: void

trigger()

Create and trigger an event.

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

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

Parameter Name Type Description
$eventName string
$target null|object|string
$argv array|object

Returns: \ResponseCollection

triggerEvent()

Trigger an event

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

Parameter Name Type Description
$event \EventInterface

Returns: \ResponseCollection

triggerEventUntil()

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

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.

Parameter Name Type Description
$callback callable
$event \EventInterface

Returns: \ResponseCollection

triggerUntil()

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

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

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.

Parameter Name Type Description
$callback callable
$eventName string
$target null|object|string
$argv array|object

Returns: \ResponseCollection

Top