You are here

class EventsDataCollector in Devel 4.x

Same name and namespace in other branches
  1. 8.3 webprofiler/src/DataCollector/EventsDataCollector.php \Drupal\webprofiler\DataCollector\EventsDataCollector
  2. 8 webprofiler/src/DataCollector/EventsDataCollector.php \Drupal\webprofiler\DataCollector\EventsDataCollector
  3. 8.2 webprofiler/src/DataCollector/EventsDataCollector.php \Drupal\webprofiler\DataCollector\EventsDataCollector

Class EventsDataCollector.

Hierarchy

Expanded class hierarchy of EventsDataCollector

1 string reference to 'EventsDataCollector'
webprofiler.services.yml in webprofiler/webprofiler.services.yml
webprofiler/webprofiler.services.yml
1 service uses EventsDataCollector
webprofiler.events in webprofiler/webprofiler.services.yml
Drupal\webprofiler\DataCollector\EventsDataCollector

File

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

Namespace

Drupal\webprofiler\DataCollector
View source
class EventsDataCollector extends DataCollector implements DrupalDataCollectorInterface, LateDataCollectorInterface {
  use StringTranslationTrait, DrupalDataCollectorTrait;

  /**
   * @var \Symfony\Component\EventDispatcher\EventDispatcherInterface
   */
  private $eventDispatcher;

  /**
   * EventsDataCollector constructor.
   *
   * @param \Symfony\Component\EventDispatcher\EventDispatcherInterface $event_dispatcher
   */
  public function __construct(EventDispatcherInterface $event_dispatcher) {
    $this->eventDispatcher = $event_dispatcher;
  }

  /**
   * {@inheritdoc}
   */
  public function collect(Request $request, Response $response, \Exception $exception = NULL) {
    $this->data = [
      'called_listeners' => [],
      'called_listeners_count' => 0,
      'not_called_listeners' => [],
      'not_called_listeners_count' => 0,
    ];
  }

  /**
   * {@inheritdoc}
   */
  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,
      ];
    }
  }

  /**
   * @return array
   */
  public function getCalledListeners() {
    return $this->data['called_listeners'];
  }

  /**
   * @return array
   */
  public function getNotCalledListeners() {
    return $this->data['not_called_listeners'];
  }

  /**
   * @return int
   */
  public function getCalledListenersCount() {
    return $this->data['called_listeners_count'];
  }

  /**
   * @return int
   */
  public function getNotCalledListenersCount() {
    return $this->data['not_called_listeners_count'];
  }

  /**
   * {@inheritdoc}
   */
  public function getName() {
    return 'events';
  }

  /**
   * @return mixed
   */
  public function getData() {
    return $this->data;
  }

  /**
   * {@inheritdoc}
   */
  public function getTitle() {
    return $this
      ->t('Events');
  }

  /**
   * {@inheritdoc}
   */
  public function getPanelSummary() {
    return $this
      ->t('Called listeners: @listeners', [
      '@listeners' => $this
        ->getCalledListenersCount(),
    ]);
  }

  /**
   * {@inheritdoc}
   */
  public function getIcon() {
    return 'iVBORw0KGgoAAAANSUhEUgAAABUAAAAcCAYAAACOGPReAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAABFJJREFUeNrkVVlIY2cY/RMTE81NMkkajUs1OBqkiVsjjAtStGrtSGyFjOjAQNVCKRb66ot9KrjgQx+FUgTBKkURbIfighWl4r6h44pajcZEo3ESTeKS9PzB2AyNZaD1qRcOem+S83/f+c53Lsvj8ZD/+mKTB7gehJTj+2d9fZ1MTk6S0NBQSW9vb97e3t7jmpqaXzIzM185HA7vd4KDg8nGxoaysbGxVCwWm/V6/aDL5TKlpKSQpKSkv5NyuVxyc3Mj7e7u/jw2NjYxJyfnMDIykmGz2UQgEBAWi0XcbjeRSqWhZWVl4v39fXVXV5cqNzf3exx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Alv8PACXa/Q4L4UByuZqbm/UNDQ1vkLL+3+/9ByH9U4ABADscgvUMKuLiAAAAAElFTkSuQmCC';
  }

}

Members

Namesort descending Modifiers Type Description Overrides
DrupalDataCollectorInterface::getDrupalSettings public function 1
DrupalDataCollectorInterface::getLibraries public function Returns the libraries needed in detail panel. 2
DrupalDataCollectorInterface::hasPanel public function Returns true if this datacollector has a detail panel. 2
EventsDataCollector::$eventDispatcher private property
EventsDataCollector::collect public function
EventsDataCollector::getCalledListeners public function
EventsDataCollector::getCalledListenersCount public function
EventsDataCollector::getData public function Overrides DrupalDataCollectorInterface::getData
EventsDataCollector::getIcon public function Returns the collector icon in base64 format. Overrides DrupalDataCollectorInterface::getIcon
EventsDataCollector::getName public function Returns the name of the collector. Overrides DrupalDataCollectorInterface::getName
EventsDataCollector::getNotCalledListeners public function
EventsDataCollector::getNotCalledListenersCount public function
EventsDataCollector::getPanelSummary public function Returns the string used in vertical tab summary. Overrides DrupalDataCollectorInterface::getPanelSummary
EventsDataCollector::getTitle public function Returns the datacollector title. Overrides DrupalDataCollectorInterface::getTitle
EventsDataCollector::lateCollect public function
EventsDataCollector::__construct public function EventsDataCollector constructor.
StringTranslationTrait::$stringTranslation protected property The string translation service. 4
StringTranslationTrait::formatPlural protected function Formats a string containing a count of items.
StringTranslationTrait::getNumberOfPlurals protected function Returns the number of plurals supported by a given language.
StringTranslationTrait::getStringTranslation protected function Gets the string translation service.
StringTranslationTrait::setStringTranslation public function Sets the string translation service to use. 2
StringTranslationTrait::t protected function Translates a string to the current language or to a given language.