Finds the route definition.

@param string $routeName
@return null|\Symfony\Component\Routing\Route
320213
public function findRoute($routeName)
    {
        // TODO create a route finder ? (same in CmsBundle BreadcrumbBuilder)
        $i18nRouterClass = 'JMS\I18nRoutingBundle\Router\I18nRouterInterface';
        if (interface_exists($i18nRouterClass) && $this->router instanceof $i18nRouterClass) {
            $route = $this->router->getOriginalRouteCollection()->get($routeName);
        } else {
            $route = $this->router->getRouteCollection()->get($routeName);
        }
        if (null === $route) {
            throw new \RuntimeException(sprintf('Route "%s" not found.', $routeName));
        }
        return $route;
    }
756513
public function getRouteGroup(string $groupName): \Nofuzz\Route\Group
  {
    foreach ($this->routeGroups as $routeGroup)
    {
      if ( strcasecmp($routeGroup->getName(),$groupName)==0 ) {
        return $routeGroup;
      }
    }

    return null;
  }
1338719
private function resolveName($name)
    {
        if ($name !== null) {
            return $name;
        }

        if (!isset($this->defaults['route'])) {
            throw new RouterException('Unable to make "self" url - default route was not defined.');
        }

        return $this->defaults['route'];
    }
336766
public function findByName($name)
	{
		return $this->routes->first(function ($route) use($name)
		{
			return $route->getName() === $name;
		});
	}
343702
private function getRouteByName($routeName)
    {
        if (isset($this->app->router) && $this->app->router instanceof \Laravel\Lumen\Routing\Router) {
            $router = $this->app->router;
        } else {
            // backward compatibility with lumen 5.3
            $router = $this->app;
        }
        foreach ($router->getRoutes() as $route) {
            if (isset($route['action']['as']) && $route['action']['as'] == $routeName) {
                return $route;
            }
        }
        $this->fail("Route with name '$routeName' does not exist");
        return null;
    }
1228357
public function find($url)
    {
        if (!array_key_exists($url, $this->controllerMap)) {
            return null;
        }

        return $this->controllerMap[$url];
    }
942536
private function resolveRouteOptions(Route $route, $routeName)
    {
        if (null === $cmsOptions = $route->getOption('_cms')) {
            throw new \InvalidArgumentException(sprintf('Route "%s" does not have "_cms" defaults attributes.', $routeName));
        }

        $path = $route->getPath();

        $dynamic = false;
        if (preg_match_all('~\{([^\}]+)\}~', $path, $matches, PREG_SET_ORDER)) {
            foreach ($matches as $match) {
                // If route parameter does not have a default value
                if (!array_key_exists($match[1], $route->getDefaults())) {
                    $dynamic = true;
                    break;
                }
            }
        }

        return $this->optionsResolver->resolve(array_merge($cmsOptions, [
            'path'    => $path,
            'dynamic' => $dynamic,
        ]));
    }
1165350
public function getRoute($name, array $params = null)
    {
        if (!isset($this->routes[ $name ])) {
            throw new RouteNotFoundException('The path does not exist.');
        }

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

        $prefix = !$this->isRewrite()
            ? '?'
            : '';

        $path = $route[ 'path' ];

        if (!empty($params) && isset($route[ 'with' ])) {
            foreach ($route[ 'with' ] as $key => $value) {
                if (!preg_match('/^' . $value . '$/', $params[ $key ])) {
                    throw new RouteArgumentException($params[ $key ], $value, $path);
                }
                $path = str_replace($key, $params[ $key ], $path);
            }
        }

        return $this->basePath . $prefix . $path;
    }
1149973
private function hasRoute($routePattern, $routeName)
    {
        if (!$routeName) {
            throw new RoutingRuntimeException('Route name is empty!');
        }

        $route = $this->routeManager->findByRoutePattern($routePattern);

        return ((null !== $route) && ($routeName !== $route->getName()));
    }
401719
protected function getModelRouteNameSegment($routeName = null)
    {
        $routeName = $routeName ?: $this->getRouteName();

        $combinedPrefix = config('cms-core.route.name-prefix')
                        . config('cms-models.route.name-prefix')
                        . static::MODEL_ROUTE_NAME_PREFIX;

        if ( ! starts_with($routeName, $combinedPrefix)) {
            return false;
        }

        return substr($routeName, strlen($combinedPrefix));
    }
545481
public function seeCurrentRouteIs($routeName, array $params = [])
    {
        $router = $this->grabService('router');
        if (!$router->getRouteCollection()->get($routeName)) {
            $this->fail(sprintf('Route with name "%s" does not exists.', $routeName));
        }

        $uri = explode('?', $this->grabFromCurrentUrl())[0];
        try {
            $match = $router->match($uri);
        } catch (\Symfony\Component\Routing\Exception\ResourceNotFoundException $e) {
            $this->fail(sprintf('The "%s" url does not match with any route', $uri));
        }
        $expected = array_merge(['_route' => $routeName], $params);
        $intersection = array_intersect_assoc($expected, $match);

        $this->assertEquals($expected, $intersection);
    }
561906
protected function findRouteRecursively($routeName)
    {
        // alias check
        if(is_string($routeName)) {
            if(isset($this->aliasIndices[$routeName])) {
                $routeName = $this->aliasIndices[$routeName];
            } else {
                foreach($this->groupAliasIndices as $alias => $name) {
                    if(strpos($routeName, $alias) === 0) {
                        $routeName = substr_replace($routeName, $name, 0, strlen($alias));
                        break;
                    }
                }
            }
        }

        $routeNames = !is_array($routeName) ? explode('.', $routeName) : $routeName;
        $routeName = array_shift($routeNames);
        $isTag = strpos($routeName, '#') === 0;

        // search by route name
        if(!$isTag)
        {
            // loop this group, and find the route.
            foreach($this->storage as $route)
            {
                if($route->getName() === $routeName)
                {
                    // still has depth
                    if(count($routeNames) > 0)
                        if($route->hasSubroutes())
                            return $route->getSubroutes()->findRouteRecursively($routeNames);
                        else
                            return false;

                    return $route;
                }
            }
        }
        // search by route tag under this group.
        else
        {
            $route = $this->findRouteByTag(substr($routeName, 1));

            if($route)
            {
                if(count($routeNames) > 0)
                    if($route->hasSubroutes())
                        return $route->getSubroutes()->findRouteRecursively($routeNames);
                    else
                        return false;

                return $route;
            }
        }

        return false;
    }
279598
public function getRoute(string $name = null, ...$args)
    {
        if (is_null($name)) {
            return $this->get('route');
        }

        return $this->get('route', $name, ...$args);
    }
929120
public function getPageByName($routeName)
    {
        @trigger_error(
            'The '.__METHOD__.' method is deprecated since version 3.2 and will be removed in 4.0.',
            E_USER_DEPRECATED
        );

        $snapshots = $this->getEntityManager()->createQueryBuilder()
            ->select('s')
            ->from($this->class, 's')
            ->where('s.routeName = :routeName')
            ->setParameters([
                'routeName' => $routeName,
            ])
            ->getQuery()
            ->execute();

        $snapshot = \count($snapshots) > 0 ? $snapshots[0] : false;

        if ($snapshot) {
            return new SnapshotPageProxy($this, $snapshot);
        }

        return false;
    }
317204
protected function searchDefinitionByName($name)
    {
        foreach ($this->getGroupAndSortingDefinition() as $definition) {
            if ($name === $definition->getName()) {
                return $definition;
            }
        }

        return null;
    }
939432
public function getRouteByName($name)
    {
        if (!isset($this->routes[$name])) {
            return null;
        }
        return $this->routes[$name];
    }
961119
public function isFromRoute($routeName)
    {
        $session = $this->getSession();

        /** @noinspection PhpUndefinedFieldInspection */
        if ($session->data === null || !is_array($session->source)) {
            return null;
        }

        /** @noinspection PhpUndefinedFieldInspection */
        return $session->source['routeName'] === $routeName;
    }