Store route objects indexed by request method.

@param string $name
@param Proem\Routing\RouteInterface $route
15805
public function attach($name, RouteInterface $route)
    {
        $options = $route->getOptions();
        if (isset($options['method'])) {
            $this->routes[strtoupper($options['method'])][$name] = $route;
        } else {
            $this->routes['*'][$name] = $route;
        }

        return $this;
    }
250157
protected function createRoute(RouteInterface $route, Request $request)
    {
        $routePath = $this->decodePathInfo($request->getPathInfo());

        if ($route->isHistory()) {
            return new Route(
                $routePath,
                [
                    '_controller' => 'SuluWebsiteBundle:Redirect:redirect',
                    'url' => $request->getSchemeAndHttpHost()
                        . $this->requestAnalyzer->getResourceLocatorPrefix()
                        . $route->getTarget()->getPath()
                        . ($request->getQueryString() ? ('?' . $request->getQueryString()) : ''),
                ]
            );
        }

        $symfonyRoute = $this->proxyFactory->createProxy(
            Route::class,
            function(&$wrappedObject, LazyLoadingInterface $proxy, $method, array $parameters, &$initializer) use (
                $routePath,
                $route,
                $request
            ) {
                $initializer = null; // disable initialization
                $wrappedObject = new Route(
                    $routePath,
                    $this->routeDefaultsProvider->getByEntity(
                        $route->getEntityClass(),
                        $route->getEntityId(),
                        $request->getLocale()
                    )
                );

                return true;
            }
        );

        return $this->symfonyRouteCache[$route->getId()] = $symfonyRoute;
    }
246717
public function addOnRoute($name, array $routes)
    {
        $route = $this->findRoute($name);

        // if has subroutes, use the that subroutes, else, create a new subroute.
        if($route->hasSubroutes())
            $route->getSubroutes()->addRoutes($routes);
        else
            $route->setSubroutes($routes);

        return $this;
    }
1201327
protected function addToCollections($route)
    {
        $domainAndUri = $route->getDomain().$route->uri();

        if ($route->hasCondition() && ! empty($route->getConditionParameters())) {
            $domainAndUri .= serialize($route->getConditionParameters());
        }

        foreach ($route->methods() as $method) {
            $this->routes[$method][$domainAndUri] = $route;
        }

        $this->allRoutes[$method.$domainAndUri] = $route;
    }
1330474
private function addRoute($name, array $route)
    {
        extract($this->defaults($route));

        $requirements[RouteCollectionBuilder::K_NAME] = $name;

        $this->builder->addRoute($method, $pattern, $handler, $requirements, $defaults);
    }
1017894
public function save(PageInterface $page)
    {
        if (!$page->getId() && !$page->getContentRoute()->getTemplateName()) {
            $page->setContentRoute(new ContentRoute());
        }
        $this->_em->persist($page);
    }
818713
public function routeExists(string $name): bool
    {
        return null !== $this->router->getRouteCollection()->get($name);
    }
283150
public function add(Route $route, array $options = [])
    {
        $this->_routes[] = $route;

        // Explicit names
        if (isset($options['_name'])) {
            if (isset($this->_named[$options['_name']])) {
                $matched = $this->_named[$options['_name']];
                throw new DuplicateNamedRouteException([
                    'name' => $options['_name'],
                    'url' => $matched->template,
                    'duplicate' => $matched,
                ]);
            }
            $this->_named[$options['_name']] = $route;
        }

        // Generated names.
        $name = $route->getName();
        if (!isset($this->_routeTable[$name])) {
            $this->_routeTable[$name] = [];
        }
        $this->_routeTable[$name][] = $route;

        // Index path prefixes (for parsing)
        $path = $route->staticPath();
        $this->_paths[$path][] = $route;

        $extensions = $route->getExtensions();
        if (count($extensions) > 0) {
            $this->setExtensions($extensions);
        }
    }
485250
protected function storeRoute(array $methods, array $route)
    {
        $this->callbacks[] = (object)$route;
        $index             = count($this->callbacks) - 1;

        if (!isset($this->routes[$route['pattern']])) {
            $this->routes[$route['pattern']] = [];
        }

        if ($route['name']) {
            $this->names[$route['name']] = $index;
        }

        foreach ($methods as $method) {
            $this->routes[$route['pattern']][strtoupper($method)] = $index;
        }
    }
665921
public function attach($name, RouteInterface $route)
    {
        if ($this->groupAttributes !== null) {
            // This route is part of a group of routes that share common attributes.
            // Merge those attributes with the existing options.
            $route->setOptions($this->groupAttributes);
        }

        $options = $route->getOptions();
        $method  = isset($options['method']) ? strtoupper($options['method']) : '*';
        $scheme  = isset($options['scheme']) ? $options['scheme'] : $this->defaultScheme;
        $this->routes[$scheme][$method][$name] = $route;

        return $this;
    }
964028
public static function getRouteByName(string $name) : Route
    {
        foreach (static::$routes as $routes) {
            /** @var Route $route */
            foreach ($routes as $route) {
                if ($route->getName() === $name) {
                    return $route;
                }
            }
        }

        return null;
    }
1317804
public function delete($name)
    {
        if (file_exists(route()->com.$name)) {
            (new Files())->deleteDir(route()->com.$name);
        }
    }
411093
private function compileRoute(Route $route, string $name): string
    {
        $compiledRoute = $route->compile();
        $matches = (bool) $compiledRoute->getVariables();

        $code = "            // {$name}\n";

        $gotoname = 'not_'.preg_replace('/[^A-Za-z0-9_]/', '', $name);

        // the offset where the return value is appended below, with indendation
        $retOffset = 12 + \strlen($code);

        // optimize parameters array
        if ($matches) {
            $vars = ["array('$name')"];
            if ($matches) {
                $vars[] = '$matches';
            }

            $code .= sprintf(
                "            \$ret = array(%s, %s, \$this->mergeDefaults(%s, %s));\n",
                self::export($name),
                sprintf(
                    'new Route(%s, %s, %s, %s, %s)',
                    self::export($route->getPattern()),
                    self::export($route->getCallback()),
                    self::export($route->getDefaults()),
                    self::export($route->getRequirements()),
                    self::export($route->getOptions())
                ),
                implode(' + ', $vars),
                self::export($route->getDefaults())
            );
        } else {
            $code .= sprintf(
                "            \$ret = array(%s, %s, %s);\n",
                self::export($name),
                sprintf(
                    'new Route(%s, %s, %s, %s, %s)',
                    self::export($route->getPattern()),
                    self::export($route->getCallback()),
                    self::export($route->getDefaults()),
                    self::export($route->getRequirements()),
                    self::export($route->getOptions())
                ),
                self::export($route->getDefaults())
            );
        }

        $code = substr_replace($code, 'return', $retOffset, 6);

        return $code;
    }
1361850
protected function createRoutes(string $name): void
    {
        $apiFile = base_path($this->moduleName().'/'.$name.'/Routes/api.php');
        if (! $this->files->exists($apiFile)) {
            $this->files->put($apiFile, $this->files->get(__DIR__.'/stubs/routes/api.stub'));
        }

        $webFile = base_path($this->moduleName().'/'.$name.'/Routes/web.php');
        if (! $this->files->exists($webFile)) {
            $this->files->put($webFile, $this->files->get(__DIR__.'/stubs/routes/web.stub'));
        }
    }
51454
protected function dump(Route $route, $name)
    {
        if (!$route->isVisible()) {
            return;
        }

        if (!in_array('GET', $route->getMethods())) {
            throw new Exception(sprintf('Only GET mehtod supported, "%s" given.', $name));
        }

        if ($route->hasContent()) {
            if ($route->isList()) {
                if ($route->isPaginated()) {
                    $this->buildPaginatedRoute($route, $name);
                } else {
                    $this->buildListRoute($route, $name);
                }
            } else {
                $this->buildContentRoute($route, $name);
            }
        } else {
            $this->logger->log(sprintf('Building route <comment>%s</comment>', $name));
            $this->builder->build($route, $name);
        }
    }
42993
public function addRoute(Route $route, $name = null)
    {
        if (null === $name) {
            // used as a flag to know which routes will need a name later
            $name = '_unnamed_route_'.spl_object_hash($route);
        }

        $this->routes[$name] = $route;

        return $this;
    }
885193
public function put(
        string $definition,
        RequestHandlerInterface $handler,
        ?string $name = null,
        $data = null
    ): Route {
        return $this->route(Method::PUT, $definition, $handler, $name, $data);
    }