Zend Framework
2.4
|
Event manager: notification system. More...
Public Member Functions | |
__construct ($identifiers=null) | |
Constructor. | |
setEventClass ($class) | |
Set the event class to utilize. | |
setSharedManager (SharedEventManagerInterface $sharedEventManager) | |
Set shared event manager. | |
unsetSharedManager () | |
Remove any shared event manager currently attached. | |
getSharedManager () | |
Get shared event manager. | |
getIdentifiers () | |
Get the identifier(s) for this EventManager. | |
setIdentifiers ($identifiers) | |
Set the identifiers (overrides any currently set identifiers) | |
addIdentifiers ($identifiers) | |
Add some identifier(s) (appends to any currently set identifiers) | |
trigger ($event, $target=null, $argv=array(), $callback=null) | |
Trigger all listeners for a given event. | |
triggerUntil ($event, $target, $argv=null, $callback=null) | |
Trigger listeners until return value of one causes a callback to evaluate to true. | |
attach ($event, $callback=null, $priority=1) | |
Attach a listener to an event. | |
attachAggregate (ListenerAggregateInterface $aggregate, $priority=1) | |
Attach a listener aggregate. | |
detach ($listener) | |
Unsubscribe a listener from an event. | |
detachAggregate (ListenerAggregateInterface $aggregate) | |
Detach a listener aggregate. | |
getEvents () | |
Retrieve all registered events. | |
getListeners ($event) | |
Retrieve all listeners for a given event. | |
clearListeners ($event) | |
Clear all listeners for a given event. | |
prepareArgs (array $args) | |
Prepare arguments. | |
Protected Member Functions | |
triggerListeners ($event, EventInterface $e, $callback=null) | |
Trigger listeners. | |
getSharedListeners ($event) | |
Get list of all listeners attached to the shared event manager for identifiers registered by this instance. | |
insertListeners ($masterListeners, $listeners) | |
Add listeners to the master queue of listeners. | |
Protected Attributes | |
$events = array() | |
$eventClass = 'Zend\EventManager\Event' | |
$identifiers = array() | |
$sharedManager = null | |
Event manager: notification system.
Use the EventManager when you want to create a per-instance notification system for your objects.
__construct | ( | $identifiers = null | ) |
Constructor.
Allows optionally specifying identifier(s) to use to pull signals from a SharedEventManagerInterface.
null | string | int | array | Traversable | $identifiers |
addIdentifiers | ( | $identifiers | ) |
Add some identifier(s) (appends to any currently set identifiers)
string | int | array | Traversable | $identifiers |
Implements EventManagerInterface.
attach | ( | $event, | |
$callback = null , |
|||
$priority = 1 |
|||
) |
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.
string | array | ListenerAggregateInterface | $event | An event or array of event names. If a ListenerAggregateInterface, proxies to attachAggregate(). |
callable | int | $callback | If string $event provided, expects PHP callback; for a ListenerAggregateInterface $event, this will be the priority |
int | $priority | If provided, the priority at which to register the callable |
Exception\InvalidArgumentException |
Implements EventManagerInterface.
attachAggregate | ( | ListenerAggregateInterface | $aggregate, |
$priority = 1 |
|||
) |
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.
ListenerAggregateInterface | $aggregate | |
int | $priority | If provided, a suggested priority for the aggregate to use |
Implements EventManagerInterface.
clearListeners | ( | $event | ) |
Clear all listeners for a given event.
string | $event |
Implements EventManagerInterface.
detach | ( | $listener | ) |
Unsubscribe a listener from an event.
CallbackHandler | ListenerAggregateInterface | $listener |
Exception\InvalidArgumentException | if invalid listener provided |
Implements EventManagerInterface.
detachAggregate | ( | ListenerAggregateInterface | $aggregate | ) |
Detach a listener aggregate.
Listener aggregates accept an EventManagerInterface instance, and call detach() of all previously attached listeners.
ListenerAggregateInterface | $aggregate |
Implements EventManagerInterface.
getEvents | ( | ) |
getIdentifiers | ( | ) |
getListeners | ( | $event | ) |
Retrieve all listeners for a given event.
string | $event |
Implements EventManagerInterface.
|
protected |
Get list of all listeners attached to the shared event manager for identifiers registered by this instance.
string | $event |
getSharedManager | ( | ) |
Get shared event manager.
If one is not defined, but we have a static instance in StaticEventManager, that one will be used and set in this instance.
If none is available in the StaticEventManager, a boolean false is returned.
Implements SharedEventManagerAwareInterface.
|
protected |
Add listeners to the master queue of listeners.
Used to inject shared listeners and wildcard listeners.
PriorityQueue | $masterListeners | |
array | Traversable | $listeners |
prepareArgs | ( | array | $args | ) |
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().
array | $args |
setEventClass | ( | $class | ) |
Set the event class to utilize.
string | $class |
Implements EventManagerInterface.
setIdentifiers | ( | $identifiers | ) |
Set the identifiers (overrides any currently set identifiers)
string | int | array | Traversable | $identifiers |
Implements EventManagerInterface.
setSharedManager | ( | SharedEventManagerInterface | $sharedEventManager | ) |
Set shared event manager.
SharedEventManagerInterface | $sharedEventManager |
Implements SharedEventManagerAwareInterface.
trigger | ( | $event, | |
$target = null , |
|||
$argv = array() , |
|||
$callback = null |
|||
) |
Trigger all listeners for a given event.
string | EventInterface | $event | |
string | object | $target | Object calling emit, or symbol describing target (such as static method name) |
array | ArrayAccess | $argv | Array of arguments; typically, should be associative |
null | callable | $callback | Trigger listeners until return value of this callback evaluate to true |
Exception\InvalidCallbackException |
Implements EventManagerInterface.
|
protected |
Trigger listeners.
Actual functionality for triggering listeners, to which trigger() delegate.
string | $event | Event name |
EventInterface | $e | |
null | callable | $callback |
triggerUntil | ( | $event, | |
$target, | |||
$argv = null , |
|||
$callback = null |
|||
) |
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.
string | EventInterface | $event | |
string | object | $target | Object calling emit, or symbol describing target (such as static method name) |
array | ArrayAccess | $argv | Array of arguments; typically, should be associative |
callable | $callback |
Exception\InvalidCallbackException | if invalid callable provided |
Implements EventManagerInterface.
unsetSharedManager | ( | ) |
Remove any shared event manager currently attached.
Implements SharedEventManagerAwareInterface.
|
protected |
|
protected |
|
protected |
|
protected |