Adds an event listener for all events matching the specified pattern.

This method will lazily register the listener when a matching event is
dispatched.

@param ListenerPattern $pattern
194362
protected function addListenerPattern(ListenerPattern $pattern)
    {
        $this->patterns[$pattern->getEventPattern()][] = $pattern;

        foreach ($this->syncedEvents as $eventName => $_) {
            if ($pattern->test($eventName)) {
                unset($this->syncedEvents[$eventName]);
            }
        }
    }
1232790
protected function callListenerBindings(Listener $listener, Event $event)
    {
        $binding = $listener->determineEventBinding($event);

        if ($listener->hasBinding($binding)) {
            foreach ($listener->getBindings($binding) as $callback) {
                $resource = $event->getResource();

                call_user_func($callback, $resource, $resource->getPath());
            }
        }

        // If a listener has a binding for anything we'll also spin through
        // them and call each of them.
        if ($listener->hasBinding('*')) {
            foreach ($listener->getBindings('*') as $callback) {
                $resource = $event->getResource();

                call_user_func($callback, $event, $resource, $resource->getPath());
            }
        }
    }
566449
public function map($pattern, $handler = null, $methods = '*')
    {
        $this->routes[$pattern] = [
            'handler' => $handler,
            'methods' => $methods,
        ];
    }
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);
            }
        }
    }
786814
public function head(string $pattern, $stages): void
    {
        $pipeline = new HttpPipeline(RequestMethodInterface::METHOD_HEAD, $this->prefix.$pattern, $this->routerStages);
        $pipeline->pipe($stages);
        $this->pipelineCollection->add($pipeline);
    }
41165
public void setPattern(String pattern) throws IllegalArgumentException{
		if (pattern == null) {
			throw new IllegalArgumentException("The pattern must not be null.");
		}

		this.pattern = pattern;
		parsePattern(this.pattern);
	}
924873
public function setParamsPattern($pattern) {
		$this->paramsPattern   = (string) $pattern;
		$this->paramExpression = null;
		
		return $this;
	}
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;
        }
    }
870302
private function addListenerServicePattern($eventPattern, $callback, $priority = 0)
    {
        if (!is_array($callback) || 2 !== count($callback)) {
            throw new \InvalidArgumentException('Expected an array("service", "method") argument');
        }

        $container = $this->container;
        $listenerProvider = function() use ($container, $callback) {
            return array($container->get($callback[0]), $callback[1]);
        };

        $this->addListenerPattern(new LazyListenerPattern($eventPattern, $listenerProvider, $priority));
    }
299154
public function psubscribe($pattern /* ... */)
    {
        $this->writeRequest(self::PSUBSCRIBE, func_get_args());
        $this->statusFlags |= self::STATUS_PSUBSCRIBED;
    }
1019335
public function post(string $pattern, array $param) : void
    {
        $this->call('post', $pattern, $param[0], $param[1], $param);
    }
743788
public function register($class, $pattern = null, $sort = null)
    {
        $reflection = new ClassReflection($class, $pattern, $sort);

        if (!$reflection->isSubclassOf(BaseMock::class)) {
            throw new \RuntimeException("Mock classes '$class' does not extend from BaseMock");
        }

        if (!$reflection->getPattern()) {
            throw new \RuntimeException("No `pattern` defined for class '$class'");
        }
        $this->_classes[] = $reflection;

        return $reflection;
    }
58814
protected function loadPattern($patternName, array $pattern)
    {
        $pattern['matcher'] = new RequestMatcher($pattern['path']);

        $this->patterns[$patternName] = $pattern;

        return $this;
    }
468540
public static function match($pattern, $event)
    {
        if (strpos($pattern, '*') === false) {
            return $event == $pattern;
        }

        $event   = explode('.', $event);
        $pattern = explode('.', $pattern);

        if (count($event) != ($count = count($pattern))) {
            return false;
        }

        for ($i = 0; $i < $count; $i++) {
            if ($pattern[$i] != '*' && $pattern[$i] != $event[$i]) {
                return false;
            }
        }

        return true;
    }
791025
function (pattern) {
            var
                parser = new PatternParser();
            parser.parse(pattern, null);
            this._patternItem = parser.patternItem();
        }
698243
private function bindEventListenersEvents()
	{
		if ($this->_eventListeners && !$this->_listenerInstances) {
			foreach ($this->_eventListeners as $listener) {
                
				$listener = static::getListener($listener);
				
				$events = $listener->events();
				
				if ($events) foreach ($events as $name => $handler) {
					static::on($name, is_string($handler) ? [$listener, $handler] : $handler);
				}
			}
		}
	}
301901
public function addListener($event, $method)
    {
        if (!isset($this->listeners[$event])) {
            $this->listeners[$event] = array();
        }

        $this->listeners[$event][] = $method;
    }