function ContainerAwareEventDispatcher::removeSubscriber

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

phpcs:ignore Drupal.Commenting.FunctionComment.VoidReturn

Return value

void

File

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

Class

ContainerAwareEventDispatcher
A performance optimized container aware event dispatcher.

Namespace

Drupal\Component\EventDispatcher

Code

public function removeSubscriber(EventSubscriberInterface $subscriber) {
    foreach ($subscriber->getSubscribedEvents() as $event_name => $params) {
        if (is_array($params) && is_array($params[0])) {
            foreach ($params as $listener) {
                $this->removeListener($event_name, [
                    $subscriber,
                    $listener[0],
                ]);
            }
        }
        else {
            $this->removeListener($event_name, [
                $subscriber,
                is_string($params) ? $params : $params[0],
            ]);
        }
    }
}

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