@since 1.0

@param string $event
@param EventListener $listener

@throws InvalidArgumentException
350416
public function registerListener( $event, EventListener $listener ) {

		if ( !is_string( $event ) ) {
			throw new InvalidArgumentException( "Event is not a string" );
		}

		$this->addToCollection( $event, $listener );
	}
248083
protected function makeListeners($event, $listeners)
    {
        foreach ($listeners as $listener) {
            $listener = preg_replace('/@.+$/', '', $listener);

            $this->callSilent('make:listener', array_filter(
                ['name' => $listener, '--event' => $event]
            ));
        }
    }
619679
public function removeListener(string $eventName, $listener): void
    {
        $this->dispatcher->removeListener($eventName, $listener);
    }
347288
public function setListener($event, callable $listener)
    {
        if (!is_string($event) || empty($event)) {
            throw new \InvalidArgumentException('The event name is invalid');
        }

        $this->listeners[$event] = $listener;
    }
1319178
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;
        }
    }
594617
public function on($event, callable $listener)
    {

        if (strpos($event, '*') !== false) {
            $this->anyListeners[] = $this->toWildcardListener($event, $listener);
            return $this;
        }

        self::parentOn($event, $listener);

        return $this;
    }
17791
protected function setupWildcardListen($event, $listener)
    {
        $this->wildcards[$event][] = $this->makeListener($listener, true);

        $this->wildcardsCache = [];
    }
612196
public function onMessage($handler)
    {
        if (!is_callable($handler)) {
            throw new InvalidArgumentException('Message handler should be callable.');
        }
        $this->eventDispatcher->addListener(static::EVENT_MESSAGE, function (Event $event) use ($handler) {
            $handler($event->getArgument('message'));
        });
    }
1019365
public function removeListener($event, $listener)
    {
        // shortcut to only remove a listener if they exist
        // having this allows us to simplify calling code
        if( !isset($listener) ) {
            return $this;
        }

        // listeners
        if (isset($this->listeners[$event])) {
            if (false !== ($key = array_search($listener, $this->listeners[$event]))) {
                unset($this->listeners[$event][$key]);
            }
            if( !$this->listeners[$event] ) {
                unset( $this->listeners[$event] );
            }
        }
        // listeners once
        if (isset($this->listenersOnce[$event])) {
            if (false !== ($key = array_search($listener, $this->listenersOnce[$event]))) {
                unset($this->listenersOnce[$event][$key]);
            }
            if( !$this->listenersOnce[$event] ) {
                unset( $this->listenersOnce[$event] );
            }
        }
        return $this;
    }
1361291
public function attachListener(EventListener $listener)
    {
        foreach ($listener->getEventHandlers() as $name => $method) {
            if (! is_string($name)) {
                $name = $method;
                if (strpos($method, '.') !== false) {
                    $splits = explode('.', $method);
                    $method = $splits[count($splits) - 1];
                }
            }
            $this->attachHandler($name, array(
                $listener,
                $method
            ));
        }
    }
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);

        }
    }
1305733
private function addEvent($event)
    {
        if (is_string($event)) {
            $event = Event::named($event);
        }

        if (!$event instanceof EventInterface) {
            throw new \InvalidArgumentException(
                'Events should be provides as Event instances or string, received type: ' . gettype($event)
            );
        }

        $this->events[] = $event;

        return $event;
    }
1082599
public function bind($event, callable $handler)
    {
        if (in_array($event, [self::EVENT_INIT, self::EVENT_FORK, self::EVENT_START])) {
            throw new InvalidArgumentException('You can not bind a callback for this event');
        }

        parent::bind($event, $handler);
    }
1087634
protected function storeListener($event, callable $listener)
    {
        if (!isset($this->listeners[$event])) {
            $this->listeners[$event] = [];
        }
        $this->listeners[$event][] = $listener;

        return $this;
    }
645397
private function invokeListener($listener, $event)
    {
        if (is_array($listener))
        {
            list($listenerClass, $method) = $listener;

            $listenerInstance = $this->objectManager->get($listenerClass);
            $listenerInstance->{$method}($event);
        }
        else
        {
            call_user_func($listener, $event);
        }
    }
144061
static public function setEventListener($class, $listener)
    {
    	self::$_eventListeners[Ioc::resolveClassName($class)][Ioc::resolveClassName($listener)] = $listener;
    }
117848
public function removeListener(EventListener $listener)
    {
        if (($i = array_search($listener, $this->listeners)) !== false) {
            unset($this->listeners[$i]);
        }
        return $this;
    }