Add single listener.

@param string   $event
@param callable $callable
@param int      $priority

@return  static

@since   3.0
484647
public function listen($event, $callable, $priority = ListenerPriority::NORMAL)
    {
        $this->getDispatcher()->listen($event, $callable, $priority);

        return $this;
    }
1108104
public function on($event, callable $listener)
    {
        if (is_object($event) || strpos($event, '\\')) { // looks like a class
            throw new UnsupportedParameterException('Only string based events are supported');
        }

        if (!isset($this->listeners[$event])) {
            $this->listeners[$event] = [];
        }
        $this->listeners[$event][] = $listener;

        return $this;
    }
60449
public function hook($event, callable $callback, $priority = 10)
    {
        $this->app->hook($event, $callback, $priority);
    }
929500
public function addListener( $eventName, IListener $listener, $priority = 0 )
    {
        $this->listeners[ $eventName ][ $priority ][ ] = $listener;

        unset( $this->_sorted[ $eventName ] );
    }
312728
public function listen($events, $listener, $priority=0)
    {
        return $this->getDistributor()->listen($events, $listener, $priority);
    }
1368120
public static function listen($eventId, $callable, $priority = 0)
    {
        /**
         * Closure to wrap the Symphony event dispather callbacks to make for a nicer API
         *
         * @param EventObject $eventObject
         */
        $closure = function ($eventObject) use ($callable) {

            // Get any passed in data
            $data = $eventObject->getData();

            // Work out if we should stop event propogation
            $returnValue = $callable($data, $eventObject->getEventId(), $eventObject->getOriginalId());

            if ($returnValue === false) {
                $eventObject->stopPropagation();
            }
        };

        Event::eventDispatcherInstance()->addListener($eventId, $closure, $priority);

        return new EventInstance($eventId, $closure);
    }
484362
public function on($event_name, $callback, $priority = 100) {
	    	if(!is_callable($callback)){
	    		throw new \InvalidArgumentException("Argument 'callback' is not callable.");
	    	}

	        if (!isset($this->listeners[$event_name])) {
	            $this->listeners[$event_name] = array(
	                true,  // If there's only one item, it's sorted
	                array($priority),
	                array($callback)
	            );
	        } else {
	            $this->listeners[$event_name][0] = false; // marked as unsorted
	            $this->listeners[$event_name][1][] = $priority;
	            $this->listeners[$event_name][2][] = $callback;
	        }
	    }
279040
public static function addListener(string $name, $listener, $priority = 0)
    {
        BeanFactory::getBean('eventManager')->attach($name, $listener, $priority);
    }
1244478
public function on($event, $callable)
    {
        if (!is_callable($callable) && !$callable instanceof \Closure)
            throw new \InvalidArgumentException();

        if (!isset($this->_hooks[$event]))
            $this->_hooks[$event] = array();

        $this->_hooks[$event][] = $callable;

        return $this;
    }
1249979
public function removeListener(string $eventName, callable $listener, $priority = 0): MediatorInterface
    {
        $this->checkEventName($eventName);
        if (!\array_key_exists($eventName, $this->listeners)) {
            return $this;
        }
        /**
         * @var array      $priorities
         * @var int        $atPriority
         * @var callable[] $listeners
         */
        if ('last' !== $priority) {
            $priorities = $this->listeners[$eventName];
        } else {
            $priorities = \array_reverse($this->listeners[$eventName], \true);
            $priority = 'first';
        }
        $isIntPriority = \is_int($priority);
        foreach ($priorities as $atPriority => $listeners) {
            if ($isIntPriority && $priority !== $atPriority) {
                continue;
            }
            $key = \array_search($listener, $listeners, \true);
            if (\false !== $key) {
                $this->bubbleUpUnsetListener($eventName, $atPriority, $key);
                if ('first' === $priority) {
                    break;
                }
            }
        }
        return $this;
    }
590223
public function handle(string $event, callable $callback, int $priority = 0): Route
    {
        return $this->collection->createRoute($event, $callback)->set('priority', $priority);
    }
56527
protected function offHandlerWithPriority(string $eventName, callable $handler, int $priority = 50): self
    {
        $handlerId = $this->handler->getKey($handler);

        if (isset($this->listeners[$eventName][$priority][$handlerId])) {
            unset($this->listeners[$eventName][$priority][$handlerId]);
            $this->cleanEmptyEvent($eventName, $priority);
        }

        return $this;
    }
321290
public function addListener(string $eventName, callable $listener, $priority = 0): MediatorInterface
    {
        $this->checkEventName($eventName);
        $priority = $this->getActualPriority($eventName, $priority);
        if (!(\array_key_exists($eventName, $this->listeners)
            && \array_key_exists($priority, $this->listeners[$eventName])
            && \in_array($listener, $this->listeners[$eventName][$priority], \true))
        ) {
            $this->listeners[$eventName][$priority][] = $listener;
        }
        return $this;
    }
1352106
public function attachEvent($event, $handler, $priority = 0)
    {
        $this->eventDispatcher->addListener($event, $handler, $priority);
        return $this;
    }
1359840
public function hook($name, $callable, $priority = 10)
    {
        if (!isset($this->hooks[$name])) {
            $this->hooks[$name] = array(array());
        }
        if (is_callable($callable)) {
            $this->hooks[$name][(int) $priority][] = $callable;
        }
    }
664097
protected function addEventListener($name, $callback, $priority, $accepted_args)
    {
        $this->hooks[$name] = [$callback, $priority, $accepted_args];
        $this->addFilter($name, $callback, $priority, $accepted_args);
    }
397742
public function listen($events, $listener, $priority=0)
    {

        if (!is_callable($listener)) {
            throw new InvalidArgumentException('Listener has to be callable');
        }

        foreach ((array)$events as $event) {

            if ($this->isWildcardSyntax($event)){
                $this->addWildCardListener($event, $listener, $priority);
            }
            $this->addListener($event, $listener, $priority);

        }
    }