Event manager: notification system
Use the EventManager when you want to create a per-instance notification system for your objects.
Constructor
Allows optionally specifying identifier(s) to use to pull signals from a SharedEventManagerInterface.
Parameters: | null|string|int|array|Traversable – |
---|
Set the event class to utilize
Parameters: | string – |
---|---|
Return type: | EventManager |
Get the identifier(s) for this EventManager
Return type: | array |
---|
Set the identifiers (overrides any currently set identifiers)
Parameters: | string|int|array|Traversable – |
---|---|
Return type: | EventManager Provides a fluent interface |
Add some identifier(s) (appends to any currently set identifiers)
Parameters: | string|int|array|Traversable – |
---|---|
Return type: | EventManager Provides a fluent interface |
Trigger all listeners for a given event
Can emulate triggerUntil() if the last argument provided is a callback.
Parameters: |
|
---|---|
Return type: | ResponseCollection All listener return values |
Throws : | ExceptionInvalidCallbackException |
Trigger listeners until return value of one causes a callback to evaluate to true
Triggers listeners until the provided callback evaluates the return value of one as true, or until all listeners have been executed.
Parameters: |
|
---|---|
Return type: | ResponseCollection |
Throws : | ExceptionInvalidCallbackException if invalid callable provided |
Attach a listener to an event
The first argument is the event, and the next argument describes a callback that will respond to that event. A CallbackHandler instance describing the event listener combination will be returned.
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.
Parameters: |
|
---|---|
Return type: | CallbackHandler|mixed CallbackHandler if attaching callable (to allow later unsubscribe); mixed if attaching aggregate |
Throws : | ExceptionInvalidArgumentException |
Attach a listener aggregate
Listener aggregates accept an EventManagerInterface instance, and call attach() one or more times, typically to attach to multiple events using local methods.
Parameters: |
|
---|---|
Return type: | mixed return value of {@link ListenerAggregateInterface::attach()} |
Unsubscribe a listener from an event
Parameters: | CallbackHandler|ListenerAggregateInterface – |
---|---|
Return type: | bool Returns true if event and listener found, and unsubscribed; returns false if either event or listener not found |
Throws : | ExceptionInvalidArgumentException if invalid listener provided |
Retrieve all listeners for a given event
Parameters: | string – |
---|---|
Return type: | PriorityQueue |
Clear all listeners for a given event
Parameters: | string – |
---|---|
Return type: | void |
Prepare arguments
Use this method if you want to be able to modify arguments from within a listener. It returns an ArrayObject of the arguments, which may then be passed to trigger() or triggerUntil().
Parameters: | array – |
---|---|
Return type: | ArrayObject |