public function EventManager::addEventListener

Adds an event listener that listens on the specified events.

Parameters

string|array $events The event(s) to listen on.:

object $listener The listener object.:

1 call to EventManager::addEventListener()
EventManager::addEventSubscriber in drupal/core/vendor/doctrine/common/lib/Doctrine/Common/EventManager.php
Adds an EventSubscriber. The subscriber is asked for all the events he is interested in and added as a listener for these events.

File

drupal/core/vendor/doctrine/common/lib/Doctrine/Common/EventManager.php, line 95

Class

EventManager
The EventManager is the central point of Doctrine's event listener system. Listeners are registered on the manager and events are dispatched through the manager.

Namespace

Doctrine\Common

Code

public function addEventListener($events, $listener) {

  // Picks the hash code related to that listener
  $hash = spl_object_hash($listener);
  foreach ((array) $events as $event) {

    // Overrides listener if a previous one was associated already
    // Prevents duplicate listeners on same event (same instance only)
    $this->_listeners[$event][$hash] = $listener;
  }
}