@param Request $request
@param string $url

@return Route
432059
protected function getRedirectRoute(Request $request, $url)
    {
        // redirect to linked page
        return new Route(
            $this->decodePathInfo($request->getPathInfo()),
            [
                '_controller' => 'SuluWebsiteBundle:Redirect:redirect',
                'url' => $url,
            ]
        );
    }
633354
public function replaceURLAction(Request $request)
    {
        $response = new JsonResponse();

        $response->setData(['text' => $this->urlHelper->replaceUrl($request->get('text'))]);

        return $response;
    }
1151965
public function route($route = null, array $params = array(), array $query = array())
    {
        return $this->toRoute($route, $params, $query);
    }
496692
public function route ( Request $request ) {
      $route = $this->router->findRoute( $request->path(), $request->method() );
      
      // Found the right path
      if ( $route !== NULL ) {
        $request->queryString = array_merge(
          $route->apply( $request->requestPath ),
          $request->queryString
        );
        return $this->invokeCallback( $request, $route->getHandler() );
      }
      
      // HEAD wasn't explicitly defined, but route to matching GET, strip body.
      if ( $request->method() === Method::$HEAD ) {
        $route = $this->router->findRoute( $request->path(), Method::$GET );
        if ( $route !== NULL ) {
          $request->requestMethod = Method::$GET;
          $response = $this->route( $request );
          $request->requestMethod = Method::$HEAD;
          $contentLength = strlen( $response->body() );
          return $response->body('')->length( $contentLength );
        }
      }
      
      // Not found
      return $this->invokeCallback( $request, $this->onNotFound );
    }
484873
protected function createLoginPath(Request $request)
    {
        $url = $this->loginPath;
        $url .= $this->appendNextUrl($request) ?  '?'. self::NEXT_URL_PARAMETER . '=' . $request->getPathInfo() : '';

        return $url;
    }
1216095
public function route(Request $request)
    {
        $request->setUrl($this->api->getPath($request));

        $routeParameters = $this->getRoute($request);
        if ($routeParameters) {
            $class = $routeParameters['class'];
            $function = $routeParameters['function'];
            $routeClass = new $class($this->integration, $this->api, $request);

            return $routeClass->$function();
        } else {
            return $this->api->callAPI($request);
        }
    }
664868
public function route(Request $request) {
        $httpMethod = $request->getMethod();

        if ($httpMethod === 'BREW') {
            throw new RuntimeException('I\'m a teapot!', 418);
        }

        if (!isset(self::$supportedHttpMethods[$httpMethod])) {
            throw new RuntimeException('Unsupported HTTP method: ' . $httpMethod, 501);
        }

        $path = $request->getPathInfo();
        $matches = [];

        foreach ($this->routes as $resourceName => $route) {
            if (preg_match($route, $path, $matches)) {
                break;
            }
        }

        // Path matched no route
        if (!$matches) {
            throw new RuntimeException('Not Found', 404);
        }

        // Create and populate a route instance that we want to inject into the request
        $route = new Route();
        $route->setName($resourceName);

        // Inject all matches into the route as parameters
        foreach ($matches as $key => $value) {
            if (is_string($key)) {
                $route->set($key, $value);
            }
        }

        // Store the route in the request
        $request->setRoute($route);
    }
276211
public function constructUrl(Request $request, Nette\Http\Url $url): ?string
	{
		if ($this->presenter != $request->getPresenterName()) {
			return null;
		}

		$base_url = $url->getBaseUrl();

		$action = $request->getParameter('action');
		$parameters = $request->getParameters();
		unset($parameters['action']);
		$path = ltrim($this->getPath(), '/');

		if (array_search($action, $this->actions, true) === false) {
			return null;
		}

		foreach ($parameters as $name => $value) {
			if (strpos($path, "<{$name}>") !== false && $value !== null) {
				$path = str_replace("<{$name}>", $value, $path);

				unset($parameters[$name]);
			}
		}

		$path = preg_replace_callback('/\[.+?\]/', function ($item) {
			if (strpos(end($item), '<')) {
				return '';
			}

			return end($item);
		}, $path);

		/**
		 * There are still some required parameters in url mask
		 */
		if (preg_match('/<\w+>/', $path)) {
			return null;
		}

		$path = str_replace(['[', ']'], '', $path);

		$query = http_build_query($parameters);

		return $base_url . $path . ($query ? '?' . $query : '');
	}
800527
public function routesAction(Request $request)
    {
        $routeExtractor = $this->get('phlexible_gui.route_extractor');
        $extractedRoutes = $routeExtractor->extract($request);

        $content = sprintf('Phlexible.Router.setData(%s);', json_encode(array(
            'baseUrl' => $extractedRoutes->getBaseUrl(),
            'basePath' => $extractedRoutes->getBasePath(),
            'routes' => $extractedRoutes->getRoutes(),
        )));

        return new Response($content, 200, ['Content-type' => 'text/javascript; charset=utf-8']);
    }
266752
public function route(Request $request) : Response
    {
        $method = $request->getMethod();

        /** @var ParsedRoute $route */
        foreach ($this->routeCollection->get($method) as $route) {
            $compiledRoute = $this->compiler->compile($route, $request);

            if ($compiledRoute->isMatch()) {
                $this->matchedRoute = $compiledRoute;

                return $this->dispatcher->dispatch($this->matchedRoute, $request, $this->matchedController);
            }
        }

        // If we've gotten here, we've got a missing route
        throw new HttpException(404);
    }
1222044
public function match(Request $request)
	{
		foreach ($this->routes->filterByMethod($request->getMethod()) as $route)
		{
			if ($route->isMatch($request->getPathInfo()))
			{
				return $route;
			}
		}

		return null;
	}
43985
protected function redirectTo($request)
    {
        session()->put('loginRedir', $_SERVER["REQUEST_URI"]);
        session()->put('loginRedirTime', time());
        if (!$request->expectsJson()) {
            return route('login');
        }
    }
312733
public function options(string $url, $callback): Route
    {
        $route = new Route(['OPTIONS'], $url, $callback);
        $this->addRoute($route);

        return $route;
    }
962880
protected function findRoute(Request $request)
    {
        if (! in_array($request->method(), array('GET', 'HEAD', 'OPTIONS'))) {
            return;
        }

        $uri = $request->path();

        foreach ($this->routes as $pattern => $callback) {
            if (preg_match('#^' .$pattern .'$#s', $uri, $matches)) {
                return array($callback, array_slice($matches, 1));
            }
        }
    }
1043688
public function urlsAction(Request $request)
    {
        $tid = $request->get('tid');
        $language = $request->get('language');

        $treeManager = $this->get('phlexible_tree.tree_manager');
        $stateManager = $this->get('phlexible_tree.state_manager');

        $node = $treeManager->getByNodeId($tid)->get($tid);

        $urls = [
            'preview' => '',
            'online' => '',
        ];

        if ($node) {
            $nodeUrlGenerator = $this->get('phlexible_tree.node_url_generator');
            $urls['preview'] = $nodeUrlGenerator->generatePreviewUrl($node, $language);

            if ($stateManager->isPublished($node, $language)) {
                try {
                    $urls['online'] = $nodeUrlGenerator->generateOnlineUrl($node, $language);
                } catch (\Exception $e) {
                }
            }
        }

        return new ResultResponse(true, '', $urls);
    }
512550
protected function setupRouter(Request $request)
    {
        if ($request instanceof Request\Web) {
            $router = $this->getRouter();
            if (
                $router instanceof Router\RouterCuInterface
                && $router->isRequestedUrlClean($request))
            {
                $router->enableCleanUrls();
            }
        }

        return $this;
    }
666953
public function showAction(Request $request, $url = '')
    {
        $response = $this->get('victoire_page.page_helper')->renderPageByUrl(
            $request->getUri(),
            $url,
            $request->getLocale(),
            $request->isXmlHttpRequest() ? $request->query->get('modalLayout', null) : null
        );

        return $response;
    }