src/Events/EventDispatcher.php
public function addListener(EventListener $listener, $priority = 0, $important = false)
    {
        if ($listener === $this) {
            throw new EventException("Adding self as listener in 'Events\EventDispatcher' would cause an infinite loop");
        }
        $priority = -$priority;
        while (isset($this->listeners[$priority])) {
            $priority += $important ? -1 : 1;
        }
        $this->listeners[$priority] = $listener;
        ksort($this->listeners);
        $this->processStackedEvents();
        return $this;
    }
public function addListener(EventListener $listener, $priority = 0, $important = false)
    {
        if ($listener === $this) {
            throw new EventException("Adding self as listener in 'Events\EventDispatcher' would cause an infinite loop");
        }
        $priority = -$priority;
        while (isset($this->listeners[$priority])) {
            $priority += $important ? -1 : 1;
        }
        $this->listeners[$priority] = $listener;
        ksort($this->listeners);
        $this->processStackedEvents();
        return $this;
    }
public function addListener ( EventListener $ listener , $ priority = 0 , $ important = false ) { if ( $ listener === $ this ) { throw new EventException ( "Adding self as listener in 'Events\EventDispatcher' would cause an infinite loop" ) ; } $ priority = - $ priority ; while ( isset ( $ this -> listeners [ $ priority ] ) ) { $ priority += $ important ? - 1 : 1 ; } $ this -> listeners [ $ priority ] = $ listener ; ksort ( $ this -> listeners ) ; $ this -> processStackedEvents ( ) ; return $ this ; }
Adds a new listener

@param EventListener $listener
@param integer $priority Listener's priority, higher is more important
@param boolean $important Whether this listener is more important than other ones of the same priority
Adds a new listener