Merge current events listeners with a given list.

@param ListenerQueue[]|EventManagerInterface $eventListeners event listeners by event name

@return bool true on success false on failure
161241
public function mergeEventListeners($eventListeners)
    {
        if ($eventListeners instanceof EventManagerInterface) {
            $eventListeners = $eventListeners->getEventListeners();
        }

        foreach (((array) $eventListeners) as $eventName => $listeners) {
            $queue = [];
            if (isset($this->eventListeners[$eventName])) {
                $innerListeners = clone $this->eventListeners[$eventName];
                $innerListeners->setExtractFlags(ListenerQueue::EXTR_DATA);
                foreach ($innerListeners as $callback) {
                    $queue[] = $callback;
                }
            }
            $listeners = clone $listeners;
            $listeners->setExtractFlags(ListenerQueue::EXTR_BOTH);
            foreach ($listeners as $listener) {
                if (!in_array($listener['data'], $queue)) {
                    $this->attach($eventName, $listener['data'], $listener['priority']);
                }
            }
        }

        return true;
    }
1206853
private function addListeners(array $events)
    {
        foreach ($events as $eventName => $listeners) {
            foreach ($listeners as $listener) {
                if (is_array($listener) && count($listener) === 2 && is_int($listener[1])) {
                    list($listener, $priority) = $listener;
                } else {
                    $priority = 0;
                }
                $this->dispatcher->addListener($eventName, $listener, $priority);
            }
        }

        return $this;
    }
831701
private function sortListeners(string $eventName)
	{
        $listeners = &$this->listeners[$eventName];

		\krsort($listeners);
		$this->sorted[$eventName] = \array_merge(...$listeners);
	}
830402
public function listen($events, $listener)
    {
        foreach ((array) $events as $event) {
            if (Str::contains($event, '*')) {
                $this->setupWildcardListen($event, $listener);
            } else {
                $this->listeners[$event][] = $this->makeListener($listener);
            }
        }
    }
448249
protected function callListeners(array $listeners, $args = [])
    {
        $called = false;
        foreach ($listeners as $listener) {
            Helper::call($listener, is_array($args) ? $args : [$args]);
            $called = true;
        }

        return $called;
    }
864685
private function registerEventListeners()
    {
        $listeners = $this->getListeners();
        foreach ($listeners as $listenerKey => $listenerValues) {
            foreach ($listenerValues as $listenerValue) {
                \Event::listen($listenerKey,
                    $listenerValue
                );
            }
        }
    }
389628
private function sortListeners($eventName)
    {
        $this->sorted[$eventName] = array();

        if (isset($this->listeners[$eventName])) {
            krsort($this->listeners[$eventName]);
            $this->sorted[$eventName] = call_user_func_array('array_merge', $this->listeners[$eventName]);
        }
    }
113083
public function setEventManager(EventManagerInterface $events)
    {
        $events->setIdentifiers(array(
            __CLASS__,
            get_class($this)
        ));
        $events->setSharedManager(
            $this->getContainer()->get("sharedEventManager")
        );
        $this->_events = $events;
        return $this;
    }
437817
public function addListener(string $event, $listener)
    {
        if (!isset($this->listeners[$event])) {
            $this->listeners[$event] = [];
        }
        $this->listeners[$event][] = $listener;
    }
26004
public function listen($name, $listenerInterface)
    {

        $name = is_object($name) ? get_class($name) : $name;

        if ($listenerInterface instanceof EventListener && $listenerInterface instanceof SubscriberInterface) {
            $listeners = $listenerInterface->getSubscribedEvents();

            foreach ($listeners as $listener => $callback) {
                if (!$callback instanceof Closure) {
                    $callback = [$listenerInterface, $callback];
                }

                if(is_integer($listener)){
                    EventCollector::addListener($name, $callback);

                }else{
                    EventCollector::addListener($name.'.'.$listener, $callback);
                }
            }

        } else {
            EventCollector::addListener($name, $listenerInterface);
        }

        return $this;
    }
535309
public function detach(\Zend_EventManager_EventCollection $events)
    {
        foreach($this->listeners as $index => $listener) {
            if($events->detach($listener)) {
                unset($this->listeners[$index]);
            }
        }
    }
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;
        }
    }
389584
public function detach(EventManagerInterface $events)
    {
        $sharedManager = $events->getSharedManager();

        foreach ($this->listeners as $index => $listeners) {
            if ($listeners === $this) {
                continue;
            }

            if ($listeners instanceof ListenerAggregateInterface) {
                $listeners->detach($events);
            }

            $events->detach($listeners);
        }

        /** @var array $sharedListeners */
        foreach ($this->sharedListeners as $id => $sharedListeners) {
            foreach ($sharedListeners as $index => $listener) {
                if ($listener === $this) {
                    continue;
                }

                if ($listener instanceof ListenerAggregateInterface) {
                    $listener->detach($events);
                }

                $sharedManager->detach($listener, $id);
            }
        }
    }
198161
public function attach(EventManagerInterface $events)
    {
        $eventConfigListener = new modules\EventConfigModuleListener($this->serviceLocator);

        $this->listeners[] = $events->attach(ModuleEvent::EVENT_LOAD_MODULES_POST, $eventConfigListener);
        $this->listeners[] = $events->attach(ModuleEvent::EVENT_LOAD_MODULE_RESOLVE, array($this, 'resolve'), 100);

        return $this;
    }
846844
public function attach(EventManagerInterface $events)
    {
        $this->listeners[] = $events->attach(MvcEvent::EVENT_DISPATCH, 
            array(
                $this,
                'injectPlugin'
            ), 100);
        $this->listeners[] = $events->attach(MvcEvent::EVENT_FINISH, 
            array(
                $this,
                'storeRoute'
            ), - 100);
    }
833934
public function detach(\Zend\EventManager\EventManagerInterface $oEvents) {
        foreach ($this->listeners as $iIndex => $oListener) {
            if ($oEvents->detach($oListener)) {
                unset($this->listeners[$iIndex]);
            }
        }
    }
225700
public function attach(EventManagerInterface $events)
    {
        $this->listeners[] = $events->attach(MvcEvent::EVENT_BOOTSTRAP,
            array(
                $this,
                'initialize'
            ), 1001);
        $this->listeners[] = $events->attach(MvcEvent::EVENT_BOOTSTRAP,
            array(
                $this,
                'check'
            ), 1000);
    }