attach()
attachAggregate()
clearListeners()
detach()
detachAggregate()
getEvents()
getInstance()
getListeners()
hasInstance()
resetInstance()
setInstance()
__construct()
__clone()
$identifiers
$instance
Static version of 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.
attach(string | array $id, string $event, \Zend\EventManager\callable $callback, int $priority) : \Zend\Stdlib\CallbackHandler | array
Allows attaching a callback to an event offered by one or more identifying components. As an example, the following connects to the "getAll" event of both an AbstractResource and EntityResource:
$sharedEventManager = new SharedEventManager();
$sharedEventManager->attach(
array('My\Resource\AbstractResource', 'My\Resource\EntityResource'),
'getAll',
function ($e) use ($cache) {
if (!$id = $e->getParam('id', false)) {
return;
}
if (!$data = $cache->load(get_class($resource) . '::getOne::' . $id )) {
return;
}
return $data;
}
);
inherited_from | \Zend\EventManager\SharedEventManager::attach() |
---|
stringarray
Identifier(s) for event emitting component(s)
string
\Zend\EventManager\callable
PHP Callback
int
Priority at which listener should execute
\Zend\Stdlib\CallbackHandler
array
Either CallbackHandler or array of CallbackHandlersattachAggregate(\Zend\EventManager\SharedListenerAggregateInterface $aggregate, int $priority) : mixed
Listener aggregates accept an EventManagerInterface instance, and call attachShared() one or more times, typically to attach to multiple events using local methods.
inherited_from | \Zend\EventManager\SharedEventManager::attachAggregate() |
---|
int
If provided, a suggested priority for the aggregate to use
mixed
return value of {@link ListenerAggregateInterface::attachShared()}clearListeners(string | int $id, null | string $event) : bool
inherited_from | \Zend\EventManager\SharedEventManager::clearListeners() |
---|
stringint
nullstring
bool
detach(string | int $id, \Zend\Stdlib\CallbackHandler $listener) : bool
inherited_from | \Zend\EventManager\SharedEventManager::detach() |
---|
stringint
\Zend\Stdlib\CallbackHandler
bool
Returns true if event and listener found, and unsubscribed; returns false if either event or listener not founddetachAggregate(\Zend\EventManager\SharedListenerAggregateInterface $aggregate) : mixed
Listener aggregates accept a SharedEventManagerInterface instance, and call detachShared() of all previously attached listeners.
inherited_from | \Zend\EventManager\SharedEventManager::detachAggregate() |
---|
mixed
return value of {@link SharedListenerAggregateInterface::detachShared()}getEvents(string | int $id) : array
inherited_from | \Zend\EventManager\SharedEventManager::getEvents() |
---|
stringint
array
getInstance() : \Zend\EventManager\StaticEventManager
getListeners(string | int $id, string | int $event) : false | \Zend\Stdlib\PriorityQueue
inherited_from | \Zend\EventManager\SharedEventManager::getListeners() |
---|
stringint
stringint
hasInstance() : bool
bool
resetInstance() : void
setInstance(\Zend\EventManager\SharedEventManagerInterface $instance) : void
__construct()
__clone() : void
$identifiers : array
inherited_from | \Zend\EventManager\SharedEventManager::$$identifiers |
---|