[ Index ]

PHP Cross Reference of phpBB-3.2.11-deutsch

title

Body

[close]

/vendor/zendframework/zend-eventmanager/src/ -> SharedEventManager.php (summary)

Zend Framework (http://framework.zend.com/)

Copyright: Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
License: http://framework.zend.com/license/new-bsd New BSD License
File Size: 176 lines (6 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

SharedEventManager:: (7 methods):
  attach()
  attachAggregate()
  detach()
  detachAggregate()
  getEvents()
  getListeners()
  clearListeners()


Class: SharedEventManager  - X-Ref

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.
attach($id, $event, $callback, $priority = 1)   X-Ref
Attach a listener to an event

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:

<code>
$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;
}
);
</code>

param: string|array $id Identifier(s) for event emitting component(s)
param: string $event
param: callable $callback PHP Callback
param: int $priority Priority at which listener should execute
return: CallbackHandler|array Either CallbackHandler or array of CallbackHandlers

attachAggregate(SharedListenerAggregateInterface $aggregate, $priority = 1)   X-Ref
Attach a listener aggregate

Listener aggregates accept an EventManagerInterface instance, and call attachShared()
one or more times, typically to attach to multiple events using local
methods.

param: SharedListenerAggregateInterface $aggregate
param: int $priority If provided, a suggested priority for the aggregate to use
return: mixed return value of {@link ListenerAggregateInterface::attachShared()}

detach($id, CallbackHandler $listener)   X-Ref
Detach a listener from an event offered by a given resource

param: string|int $id
param: CallbackHandler $listener
return: bool Returns true if event and listener found, and unsubscribed; returns false if either event or listener not found

detachAggregate(SharedListenerAggregateInterface $aggregate)   X-Ref
Detach a listener aggregate

Listener aggregates accept a SharedEventManagerInterface instance, and call detachShared()
of all previously attached listeners.

param: SharedListenerAggregateInterface $aggregate
return: mixed return value of {@link SharedListenerAggregateInterface::detachShared()}

getEvents($id)   X-Ref
Retrieve all registered events for a given resource

param: string|int $id
return: array

getListeners($id, $event)   X-Ref
Retrieve all listeners for a given identifier and event

param: string|int $id
param: string|int $event
return: false|PriorityQueue

clearListeners($id, $event = null)   X-Ref
Clear all listeners for a given identifier, optionally for a specific event

param: string|int $id
param: null|string $event
return: bool



Generated: Wed Nov 11 20:33:01 2020 Cross-referenced by PHPXref 0.7.1