Shared/contextual EventManager
Allows attaching to EMs composed by other classes without having an instance first. The assumption is that the SharedEventManager will be injected into EventManager instances, and then queried for additional listeners when triggering an event.
category | Zend |
---|---|
package | Zend_EventManager |
copyright | Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) |
license | New BSD License |
attach(string|array $id, string $event, callback $callback, integer $priority = 1
) : void
Allows attaching a callback to an event offerred by one or more identifying components. As an example, the following connects to the "getAll" event of both an AbstractResource and EntityResource:
SharedEventManager::getInstance()->connect(
array('My\Resource\AbstractResource', 'My\Resource\EntityResource'),
'getOne',
function ($e) use ($cache) {
if (!$id = $e->getParam('id', false)) {
return;
}
if (!$data = $cache->load(get_class($resource) . '::getOne::' . $id )) {
return;
}
return $data;
}
);
string
array
Identifier(s) for event emitting component(s)
string
callback
PHP Callback
integer
Priority at which listener should execute
clearListeners(string|integer $id, null|string $event = null
) : boolean
string
integer
null
string
boolean
detach(string|integer $id, \Zend_Stdlib_CallbackHandler $listener) : boolean
string
integer
\Zend_Stdlib_CallbackHandler
boolean
Returns true if event and listener found, and unsubscribed; returns false if either event or listener not foundgetEvents(string|integer $id) : array
string
integer
array
getListeners(string|integer $id, string|integer $event) : false | \Zend_Stdlib_PriorityQueue
inherited_from | \Zend_EventManager_SharedEventCollection::getListeners() |
---|
string
integer
string
integer
false
\Zend_Stdlib_PriorityQueue
$identifiers : array
array()