[ Index ]

PHP Cross Reference of phpBB-3.3.14-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: https://github.com/zendframework/zend-eventmanager/blob/master/LICENSE.md
File Size: 235 lines (9 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

SharedEventManager:: (4 methods):
  attach()
  detach()
  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($identifier, $event, callable $listener, $priority = 1)   X-Ref
Attach a listener to an event emitted by components with specific identifiers.

Allows attaching a listener to an event offered by an identifying
components. As an example, the following connects to the "getAll" event
of both an AbstractResource and EntityResource:

<code>
$sharedEventManager = new SharedEventManager();
foreach (['My\Resource\AbstractResource', 'My\Resource\EntityResource'] as $identifier) {
$sharedEventManager->attach(
$identifier,
'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 $identifier Identifier for event emitting component.
param: string $event
param: callable $listener Listener that will handle the event.
param: int $priority Priority at which listener should execute
return: void

detach(callable $listener, $identifier = null, $eventName = null, $force = false)   X-Ref


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

param: string[] $identifiers
param: string   $eventName
return: array[]

clearListeners($identifier, $eventName = null)   X-Ref




Generated: Mon Nov 25 19:05:08 2024 Cross-referenced by PHPXref 0.7.1