function ContainerAwareEventDispatcher::getListenerPriority
Same name in other branches
- 8.9.x core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php \Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher::getListenerPriority()
- 10 core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php \Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher::getListenerPriority()
- 11.x core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php \Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher::getListenerPriority()
File
-
core/
lib/ Drupal/ Component/ EventDispatcher/ ContainerAwareEventDispatcher.php, line 196
Class
- ContainerAwareEventDispatcher
- A performance optimized container aware event dispatcher.
Namespace
Drupal\Component\EventDispatcherCode
public function getListenerPriority($event_name, $listener) : ?int {
if (!isset($this->listeners[$event_name])) {
return NULL;
}
if (is_array($listener) && isset($listener[0]) && $listener[0] instanceof \Closure) {
$listener[0] = $listener[0]();
}
// Resolve service definitions if the listener has not been found so far.
foreach ($this->listeners[$event_name] as $priority => &$definitions) {
foreach ($definitions as &$definition) {
if (!isset($definition['callable'])) {
// Once the callable is retrieved we keep it for subsequent method
// invocations on this class.
$definition['callable'] = [
$this->container
->get($definition['service'][0]),
$definition['service'][1],
];
}
if (is_array($definition['callable']) && isset($definition['callable'][0]) && $definition['callable'][0] instanceof \Closure) {
$definition['callable'][0] = $definition['callable'][0]();
}
if ($definition['callable'] === $listener) {
return $priority;
}
}
}
return NULL;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.