Map Route

@param array $methods
@param string $pattern
@param $callable

@return RouteInterface
8932
public function map(array $methods, string $pattern, $callable) : RouteInterface
    {
        $route = $this->getRouter()->map($methods, $pattern, $callable);

        return $route;
    }
92266
private function reverseMapRoute(RouteCollectionInterface $routes, array $matches, array $map = [])
    {
        foreach ($matches = array_filter($matches[0]) as $key => $subject) {
            if (is_int($key)) {
                continue;
            }

            if (!isset($map[$key])) {
                continue;
            }


            list ($index, $name, $prefix) = $map[$key];
            try {
                $route = $routes->get($name);
            } catch (\Exception $e) {
                throw new RuntimeException('Route does not exists.');
            }

            $route = $routes->get($name);
            $args  = [];

            $keys = $route->getContext()->getVars();
            $args = array_combine($keys, array_map(function ($key) use ($matches, $prefix) {
                return isset($matches[$prefix.$key]) ? $this->getArgValue($matches[$prefix.$key]) : null;
            }, $keys));

            return [$name, $route, array_merge($route->getDefaults(), array_filter($args))];
        }

        throw new RuntimeException('No match found.');
    }
599186
public function register($method, $pattern, $callable)
    {
        /**
         * 判断是否是
         */

        if ($pattern[0] != '|') {
            //非正则表达式的匹配段
            $pattern = $this->groupurl . $pattern;
        }
        $this->router->map($method, $pattern, $callable);
        return $this;
    }
968171
public function add($method, $pattern, $callback, array $params = [])
    {
        $pattern = '/' . trim($pattern, '/');

        $pattern = rtrim($this->prefix . $pattern, '/');
        $pattern = $pattern ?: '/' . $pattern;

        if (!is_array($method)) {
            $method = [$method];
        }

        $before = $this->getParam($params, 'before');
        $after  = $this->getParam($params, 'after');
        $name   = $this->getParam($params, 'name');

        $before = $before ? explode('|', $params['before']) : [];
        $after  = $after ? explode('|', $params['after']) : [];

        $this->storeRoute($method, [
            'pattern'  => $pattern,
            'name'     => $name,
            'callback' => $callback,
            'before'   => array_merge($this->before, $before),
            'after'    => array_merge($this->after, $after),
            'args'     => [],
        ]);

        return $this;
    }
798561
public function set(array $methods, array $args): RouterInterface
    {
        list($pattern, $callable) = $args;
        $route = new Route($methods, $pattern, $callable);
        $this->setRoute($route);
        return $this;
    }
880595
public function addMap($pattern, $controller = null)
    {
        if (!is_string($controller)) {
            throw new \InvalidArgumentException(
                'Please give me controller name string. ' . ucfirst(gettype($controller)) . ' given.'
            );
        }

        if ($pattern instanceof Route) {
            throw new \LogicException('Do not use Route object in ' . get_called_class());
        }

        return parent::addRoute(null, $pattern, ['_controller' => $controller]);
    }
207765
public function map($method, $route, $handler)
    {
        $this['router']->map($method, $route, $handler);

        return $this;
    }
1169138
public function addRoute(
        string $name,
        array $methods,
        string $pattern,
        array $middlewares,
        array $handler,
        string $group = null
    ) {
        $this->routes[$name] = [
            'methods' => $methods,
            'pattern' => $pattern,
            'middlewares' => $middlewares,
            'handler' => $handler,
            'group' => $group
        ];
    }
879033
public function delete(string $pattern, callable $callback)
    {
        if ($this->requestMethod === "DELETE") {
            $this->mapRoute($pattern, $callback);
        }
    }
983108
public function filter(callable $filter, callable $controller)
    {
        $pattern = $this->getFrontController()->addController(':all', $controller)->getPattern();
        $pattern->addFilter($filter);
        return new IRoutePatternSetterAdapter($pattern);
    }
402902
public function get($uri, $pattern, array $options = [])
    {
        $options = array_merge($options, $this->filter);

        if (is_callable($pattern)) {
            $this->route->add('GET', $this->prefix . $uri, $pattern, $options);
        } else {
            $this->route->add('GET', $this->prefix . $uri, $this->namespace . $pattern, $options);
        }
    }
4236
public function map(string $pattern, array $verbs, $stages): void
    {
        $pipeline = new HttpPipeline($verbs, $this->prefix.$pattern, $this->routerStages);
        $pipeline->pipe($stages);
        $this->pipelineCollection->add($pipeline);
    }
284498
public function map(array $methods, string $pattern, $callable): MethodsInterface
    {
        $this->container('router')->map($methods, $pattern, $callable);
        return $this;
    }
350363
public function setRoute(array $methods, string $regexp, $callable): RouteInterface
    {
        return $this
            ->setMethods($methods)
            ->setRegexp($regexp)
            ->setCallback($callable);
    }
334464
public function set($method, $pattern, $action)
    {
        $method   = $this->getValidMethod($method);
        $patterns = $this->parser->parsePattern($pattern);
        $group    = new Group;

        foreach ($patterns as $pattern)
        {
            $route = new Route($this, $method, $pattern, $action);
            $group->setRoute($route);

            if (strpos($pattern, "{") !== false) {
                   $index = $this->getDynamicIndex($method, $pattern);
                   $this->dynamics[$index][$pattern] = $route;
            } else $this->statics[$method][$pattern] = $route;
        }

        return $group;
    }
937613
private function matchSequentiallyForMethods(array $methods, string $path)
    {
        if ($result = $this->matchKeyValue($path, $methods)) {
            return $result;
        }

        foreach ($methods as $currentMethod) {
            foreach ($this->routes[$currentMethod] ?? [] as $handler => $handlerData) {
                foreach ($handlerData as list($patternRoute, $extraParams)) {
                    /** @var PatternRoute $patternRoute */
                    /** @var array $extraParams */
                    if ($patternRoute->match($path, $queryParams)) {
                        return new InternalRoute($handler, \array_replace($extraParams, $queryParams));
                    }
                }
            }
        }

        return null;
    }
983170
public function allowMethods(array $methods = []): Route
    {
        $this->methods = [];
        foreach ($methods as $method) {
            $this->allowMethod($method);
        }

        return $this;
    }