You are here

public function EventsDataCollector::lateCollect in Devel 8.2

Same name and namespace in other branches
  1. 8.3 webprofiler/src/DataCollector/EventsDataCollector.php \Drupal\webprofiler\DataCollector\EventsDataCollector::lateCollect()
  2. 8 webprofiler/src/DataCollector/EventsDataCollector.php \Drupal\webprofiler\DataCollector\EventsDataCollector::lateCollect()
  3. 4.x webprofiler/src/DataCollector/EventsDataCollector.php \Drupal\webprofiler\DataCollector\EventsDataCollector::lateCollect()

File

webprofiler/src/DataCollector/EventsDataCollector.php, line 50

Class

EventsDataCollector
Class EventsDataCollector

Namespace

Drupal\webprofiler\DataCollector

Code

public function lateCollect() {
  if ($this->eventDispatcher instanceof EventDispatcherTraceableInterface) {
    $countCalled = 0;
    $calledListeners = $this->eventDispatcher
      ->getCalledListeners();
    foreach ($calledListeners as &$events) {
      foreach ($events as &$priority) {
        foreach ($priority as &$listener) {
          $countCalled++;
          $listener['clazz'] = $this
            ->getMethodData($listener['class'], $listener['method']);
        }
      }
    }
    $countNotCalled = 0;
    $notCalledListeners = $this->eventDispatcher
      ->getNotCalledListeners();
    foreach ($notCalledListeners as $events) {
      foreach ($events as $priority) {
        foreach ($priority as $listener) {
          $countNotCalled++;
        }
      }
    }
    $this->data = [
      'called_listeners' => $calledListeners,
      'called_listeners_count' => $countCalled,
      'not_called_listeners' => $notCalledListeners,
      'not_called_listeners_count' => $countNotCalled,
    ];
  }
}