function ContainerAwareEventDispatcher::addListener

Same name in other branches
  1. 9 core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php \Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher::addListener()
  2. 8.9.x core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php \Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher::addListener()
  3. 11.x core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php \Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher::addListener()

phpcs:ignore Drupal.Commenting.FunctionComment.VoidReturn

Return value

void

1 call to ContainerAwareEventDispatcher::addListener()
ContainerAwareEventDispatcher::addSubscriber in core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php
phpcs:ignore Drupal.Commenting.FunctionComment.VoidReturn

File

core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php, line 217

Class

ContainerAwareEventDispatcher
A performance optimized container aware event dispatcher.

Namespace

Drupal\Component\EventDispatcher

Code

public function addListener($event_name, $listener, $priority = 0) {
    $this->listeners[$event_name][$priority][] = [
        'callable' => $listener,
    ];
    $this->unsorted[$event_name] = TRUE;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.