You are here

public function EventManager::addEventListener in Plug 7

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.:

Return value

void

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

File

lib/doctrine/common/lib/Doctrine/Common/EventManager.php, line 96

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;
  }
}