function 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,
        ];
    }
}