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