You are here

public function ContainerAwareEventDispatcher::removeSubscriber in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php \Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher::removeSubscriber()

Removes an event subscriber.

Parameters

EventSubscriberInterface $subscriber The subscriber:

Overrides EventDispatcherInterface::removeSubscriber

File

core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php, line 225
Contains \Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher.

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, array(
          $subscriber,
          $listener[0],
        ));
      }
    }
    else {
      $this
        ->removeListener($event_name, array(
        $subscriber,
        is_string($params) ? $params : $params[0],
      ));
    }
  }
}