public function ContainerAwareEventDispatcher::addSubscriber in Service Container 7
Same name and namespace in other branches
- 7.2 lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php \Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher::addSubscriber()
File
- lib/
Drupal/ Component/ EventDispatcher/ ContainerAwareEventDispatcher.php, line 206 - Contains \Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher.
Class
- ContainerAwareEventDispatcher
- A performance optimized container aware event dispatcher.
Namespace
Drupal\Component\EventDispatcherCode
public function addSubscriber(EventSubscriberInterface $subscriber) {
foreach ($subscriber
->getSubscribedEvents() as $event_name => $params) {
if (is_string($params)) {
$this
->addListener($event_name, array(
$subscriber,
$params,
));
}
elseif (is_string($params[0])) {
$this
->addListener($event_name, array(
$subscriber,
$params[0],
), isset($params[1]) ? $params[1] : 0);
}
else {
foreach ($params as $listener) {
$this
->addListener($event_name, array(
$subscriber,
$listener[0],
), isset($listener[1]) ? $listener[1] : 0);
}
}
}
}