Event manager: notification system
Use the EventManager when you want to create a per-instance notification system for your objects.
category | Zend |
---|---|
package | Zend_EventManager |
copyright | Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) |
license | New BSD License |
__construct(null|string|integer|array|\Traversable $identifiers = null
) : void
Allows optionally specifying identifier(s) to use to pull signals from a StaticEventManager.
null
string
integer
array
\Traversable
addIdentifiers(string|integer|array|\Traversable $identifiers) : \Zend_EventManager_EventManager
string
integer
array
\Traversable
\Zend_EventManager_EventManager
attach(string|array|\Zend_EventManager_ListenerAggregate $event, callback|integer $callback= null
, integer $priority= 1
) : \Zend_Stdlib_CallbackHandler | mixed
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.
inherited_from | \Zend_EventManager_EventCollection::attach() |
---|
string
array
\Zend_EventManager_ListenerAggregate
An event or array of event names. If a ListenerAggregate, proxies to {@link attachAggregate()}.
callback
integer
If string $event provided, expects PHP callback; for a ListenerAggregate $event, this will be the priority
integer
If provided, the priority at which to register the callback
\Zend_Stdlib_CallbackHandler
mixed
CallbackHandler if attaching callback (to allow later unsubscribe); mixed if attaching aggregateattachAggregate(\Zend_EventManager_ListenerAggregate $aggregate, integer $priority = 1
) : mixed
Listener aggregates accept an EventCollection instance, and call attach() one or more times, typically to attach to multiple events using local methods.
\Zend_EventManager_ListenerAggregate
integer
If provided, a suggested priority for the aggregate to use
mixed
return value of {@link Zend_EventManager_ListenerAggregate::attach()}clearListeners(string $event) : void
inherited_from | \Zend_EventManager_EventCollection::clearListeners() |
---|
string
detach(\Zend_Stdlib_CallbackHandler|\Zend_EventManager_ListenerAggregate $listener) : boolean
inherited_from | \Zend_EventManager_EventCollection::detach() |
---|
\Zend_Stdlib_CallbackHandler
\Zend_EventManager_ListenerAggregate
\Zend_EventManager_Exception_InvalidArgumentException |
if invalid listener provided |
---|
boolean
Returns true if event and listener found, and unsubscribed; returns false if either event or listener not founddetachAggregate(\Zend_EventManager_ListenerAggregate $aggregate) : mixed
Listener aggregates accept an EventCollection instance, and call detach() of all previously attached listeners.
\Zend_EventManager_ListenerAggregate
mixed
return value of {@link Zend_EventManager_ListenerAggregate::detach()}getEvents() : array
inherited_from | \Zend_EventManager_EventCollection::getEvents() |
---|
array
getIdentifiers() : array
array
getListeners(string $event) : \Zend_Stdlib_PriorityQueue
inherited_from | \Zend_EventManager_EventCollection::getListeners() |
---|
string
\Zend_Stdlib_PriorityQueue
getSharedCollections() : false | \Zend_EventManager_SharedEventCollection
false
\Zend_EventManager_SharedEventCollection
prepareArgs(array $args) : \ArrayObject
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().
array
\ArrayObject
setEventClass(string $class) : \Zend_EventManager_EventManager
string
\Zend_EventManager_EventManager
setIdentifiers(string|integer|array|\Traversable $identifiers) : \Zend_EventManager_EventManager
string
integer
array
\Traversable
\Zend_EventManager_EventManager
setSharedCollections(\Zend_EventManager_SharedEventCollection $collections) : \Zend_EventManager_EventManager
inherited_from | \Zend_EventManager_SharedEventCollectionAware::setSharedCollections() |
---|---|
fluent | This method is part of a fluent interface and will return the same instance |
\Zend_EventManager_SharedEventCollection
\Zend_EventManager_EventManager
trigger(string $event, string|object $target= null
, array|\ArrayAccess $argv= array()
, null|callback $callback= null
) : \Zend_EventManager_ResponseCollection
Can emulate triggerUntil() if the last argument provided is a callback.
inherited_from | \Zend_EventManager_EventCollection::trigger() |
---|
string
string
object
Object calling emit, or symbol describing target (such as static method name)
array
\ArrayAccess
Array of arguments; typically, should be associative
null
callback
\Zend_EventManager_ResponseCollection
All listener return valuestriggerUntil(string $event, string|object $target, array|\ArrayAccess $argv= null
, Callable $callback= null
)
Triggers listeners until the provided callback evaluates the return value of one as true, or until all listeners have been executed.
inherited_from | \Zend_EventManager_EventCollection::triggerUntil() |
---|
string
string
object
Object calling emit, or symbol describing target (such as static method name)
array
\ArrayAccess
Array of arguments; typically, should be associative
Callable
\Zend_Stdlib_Exception_InvalidCallbackException |
if invalid callback provided |
---|
unsetSharedCollections() : void
Sets \$sharedCollections to boolean false to disable ability to lazy-load static event manager instance.
getSharedListeners(string $event) : array
string
array
insertListeners(\Zend_Stdlib_PriorityQueue $masterListeners, \Zend_Stdlib_PriorityQueue $listeners) : void
Used to inject shared listeners and wildcard listeners.
\Zend_Stdlib_PriorityQueue
\Zend_Stdlib_PriorityQueue
triggerListeners(string $event, \EventDescription $e, null|callback $callback = null
) : \ResponseCollection
Actual functionality for triggering listeners, to which both trigger() and triggerUntil() delegate.
string
Event name
\EventDescription
null
callback
\ResponseCollection
$eventClass : string
'Zend_EventManager_Event'
$events : array
array()
$identifiers : array
array()
$sharedCollections : false | null | \Zend_EventManager_StaticEventCollection
null