You are here

private function TraceableEventDispatcher::addCalledListener in Devel 4.x

Same name and namespace in other branches
  1. 8.3 webprofiler/src/EventDispatcher/TraceableEventDispatcher.php \Drupal\webprofiler\EventDispatcher\TraceableEventDispatcher::addCalledListener()
  2. 8 webprofiler/src/EventDispatcher/TraceableEventDispatcher.php \Drupal\webprofiler\EventDispatcher\TraceableEventDispatcher::addCalledListener()
  3. 8.2 webprofiler/src/EventDispatcher/TraceableEventDispatcher.php \Drupal\webprofiler\EventDispatcher\TraceableEventDispatcher::addCalledListener()

Parameters

$definition:

$event_name:

$priority:

1 call to TraceableEventDispatcher::addCalledListener()
TraceableEventDispatcher::dispatch in webprofiler/src/EventDispatcher/TraceableEventDispatcher.php

File

webprofiler/src/EventDispatcher/TraceableEventDispatcher.php, line 182

Class

TraceableEventDispatcher
Class TraceableEventDispatcher.

Namespace

Drupal\webprofiler\EventDispatcher

Code

private function addCalledListener($definition, $event_name, $priority) {
  if ($this
    ->isClosure($definition['callable'])) {
    $this->calledListeners[$event_name][$priority][] = [
      'class' => 'Closure',
      'method' => '',
    ];
  }
  else {
    $this->calledListeners[$event_name][$priority][] = [
      'class' => get_class($definition['callable'][0]),
      'method' => $definition['callable'][1],
    ];
  }
  foreach ($this->notCalledListeners[$event_name][$priority] as $key => $listener) {
    if (isset($listener['service'])) {
      if ($listener['service'][0] == $definition['service'][0] && $listener['service'][1] == $definition['service'][1]) {
        unset($this->notCalledListeners[$event_name][$priority][$key]);
      }
    }
    else {
      if ($this
        ->isClosure($listener['callable'])) {
        if (is_callable($listener['callable'], TRUE, $listenerCallableName) && is_callable($definition['callable'], TRUE, $definitionCallableName)) {
          if ($listenerCallableName == $definitionCallableName) {
            unset($this->notCalledListeners[$event_name][$priority][$key]);
          }
        }
      }
      else {
        if (get_class($listener['callable'][0]) == get_class($definition['callable'][0]) && $listener['callable'][1] == $definition['callable'][1]) {
          unset($this->notCalledListeners[$event_name][$priority][$key]);
        }
      }
    }
  }
}