Returns the listeners matching a specified pattern

@param string $eventKeyPattern Pattern to match.
@return array
775494
public function matchingListeners($eventKeyPattern)
    {
        $matchPattern = '/' . preg_quote($eventKeyPattern, '/') . '/';
        $matches = array_intersect_key(
            $this->_listeners,
            array_flip(
                preg_grep($matchPattern, array_keys($this->_listeners), 0)
            )
        );

        return $matches;
    }
761822
protected function getWildcardListeners($eventName)
    {
        $wildcards = [];

        foreach ($this->wildcards as $key => $listeners) {
            if ($this->wildcardContainsEvent($key, $eventName)) {
                $wildcards = array_merge($wildcards, $listeners);
            }
        }

        return $this->wildcardsCache[$eventName] = $wildcards;
    }
1334609
protected function addInterfaceListeners($eventName, array $listeners = [])
    {
        foreach (class_implements($eventName) as $interface) {
            if (isset($this->listeners[$interface])) {
                foreach ($this->listeners[$interface] as $names) {
                    $listeners = array_merge($listeners, (array) $names);
                }
            }
        }

        return $listeners;
    }
637509
public function getListeners(string $event) : array
    {
        if (empty($this->listeners[$event])) {
            return [];
        }

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

        return $this->sorted[$event];
    }
1025269
protected function matchEventQueues(
        /*# string */ $eventName
    )/*: EventQueueInterface */ {
        $nqueue = $this->newEventQueue();
        $names  = $this->globbingNames($eventName, $this->getEventNames());
        foreach ($names as $evtName) {
            if ($this->hasEvent($evtName)) {
                $nqueue = $nqueue->combine($this->events[$evtName]);
            }
        }
        return $nqueue;
    }
621061
private function getEventSubscribers(string $eventName): array
    {
        if ($this->isEventAllowed($eventName) === false) {
            throw new EventNotFoundException($eventName);
        }

        $result = $this->getSubscribers()[$eventName] ?? [];

        return $result;
    }
1091065
public List<DelegateListener<? extends BaseDelegateExecution>> getListeners(String eventName) {
    List<DelegateListener<? extends BaseDelegateExecution>> listenerList = getListeners().get(eventName);
    if (listenerList != null) {
      return listenerList;
    }
    return Collections.emptyList();
  }
301777
public function listeners($event_name)
    {
        // Read in our config/events file so that we have them all!
        if (! $this->have_read_from_file)
        {
            $this->readConfigFile();
        }

        if (! isset($this->listeners[$event_name]))
        {
            return [];
        }

        // The list is not sorted
        if (! $this->listeners[$event_name][0])
        {
            // Sort it!
            array_multisort($this->listeners[$event_name][1], SORT_NUMERIC, $this->listeners[$event_name][2]);

            // Mark it as sorted already!
            $this->listeners[$event_name][0] = true;
        }

        return $this->listeners[$event_name][2];
    }
1296050
protected function findDomainsByHostnamePattern($hostnamePattern)
    {
        return array_filter(
            $this->domainRepository->findAll()->toArray(),
            function ($domain) use ($hostnamePattern) {
                return fnmatch($hostnamePattern, $domain->getHostname());
            }
        );
    }
1282020
private function getListeners(ActionEvent $event): iterable
    {
        $prioritizedListeners = $this->events[$event->getName()] ?? [];

        \krsort($prioritizedListeners, SORT_NUMERIC);

        foreach ($prioritizedListeners as $listenersByPriority) {
            foreach ($listenersByPriority as $listenerHandler) {
                yield $listenerHandler;
            }
        }
    }
740763
protected function matchesPatterns($functionName)
    {
        $matches = array_filter(
            array_map(
                function ($pattern) use ($functionName) {
                    return fnmatch($pattern, $functionName);
                },
                $this->methodPatterns
            )
        );
        return !empty($matches);
    }
1238041
protected function sortEventListeners(string $eventName): array
    {
        $listeners = $this->listeners[$eventName];
        $normalised = [];

        ksort($listeners);

        foreach ($listeners as $priorityListeners) {
            foreach ($priorityListeners as $listener) {
                $normalised[] = $listener;
            }
        }

        return $normalised;
    }
435456
private function sortListeners(string $eventName)
    {
        krsort($this->listeners[$eventName]);
        $this->sorted[$eventName] = [];

        foreach ($this->listeners[$eventName] as &$listeners) {
            foreach ($listeners as $k => $listener) {
                if (\is_array($listener) && isset($listener[0]) && $listener[0] instanceof \Closure) {
                    $listener[0] = $listener[0]();
                }
                $this->sorted[$eventName][] = $listener;
            }
        }
    }
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;
    }
558893
public function getListeners($event)
    {
        if (!isset($this->listeners[$event]) || !is_array($this->listeners[$event])) {
            return array();
        }
        
        return $this->listeners[$event];
    }
656524
protected function getMatchedQueue(
        /*# : string */ $eventName
    )/*# : EventQueueInterface */ {
        if ($this->hasEvent($eventName)) {
            return $this->events[$eventName];
        } else {
            return $this->newEventQueue();
        }
    }
831701
private function sortListeners(string $eventName)
	{
        $listeners = &$this->listeners[$eventName];

		\krsort($listeners);
		$this->sorted[$eventName] = \array_merge(...$listeners);
	}