@param RouterInterface $router
@param string $route
@param array $params

@return View
773786
public function createView(RouterInterface $router, $route, $params)
    {
        $view = new View();

        $view->count = $this->getNbPages();
        $view->currentPage = $this->getCurrentPage();
        $view->pages = $this->getPagerLinks($router, $route, $params);
        /** @noinspection PhpParamsInspection */
        $view->first = reset($view->pages);
        /** @noinspection PhpParamsInspection */
        $view->last = end($view->pages);
        $view->next = $this->hasNextPage() ? $view->pages[$view->currentPage + 1] : null;
        $view->prev = $this->hasPreviousPage() ? $view->pages[$view->currentPage - 1] : null;

        return $view;
    }
1335892
protected function path($route, array $params = [], array $queryParams = [])
    {
        return $this->container['router']->pathFor($route, $params, $queryParams);
    }
516781
public function dispatch(\Parable\Routing\Route $route)
    {
        $this->dispatchedRoute = $route;

        $this->hook->trigger(self::HOOK_DISPATCH_BEFORE, $route);
        $controller = null;

        // Start output buffering and set $returnContent to null
        $returnContent = null;
        $this->response->startOutputBuffer();

        // Build the parameters array
        $parameters = [];
        foreach ($route->getValues() as $value) {
            $parameters[] = $value;
        }

        // Call the relevant code
        if ($route->hasControllerAndAction()) {
            $controller = \Parable\DI\Container::get($route->getController());
            $returnContent = $controller->{$route->getAction()}(...$parameters);
        } elseif ($route->hasCallable()) {
            $callable = $route->getCallable();
            $returnContent = $callable(...$parameters);
        }

        $this->hook->trigger(self::HOOK_DISPATCH_TEMPLATE_BEFORE, $route);

        // If the route has no template path, attempt to build one based on controller/action.phtml
        if (!$route->hasTemplatePath() && $route->hasControllerAndAction()) {
            $reflection = new \ReflectionClass($controller);
            $controllerName = str_replace('\\', '/', $reflection->getName());
            $controllerName = str_replace('Controller/', '', $controllerName);

            $templatePathGenerated = $this->path->getDir(
                "app/View/{$controllerName}/{$route->getAction()}.phtml"
            );

            if (file_exists($templatePathGenerated)) {
                $route->setTemplatePath($templatePathGenerated);
            }
        }

        // And check again, now that we might have a magic template path
        if ($route->hasTemplatePath()) {
            $templatePath = $this->path->getDir($route->getTemplatePath());
            $this->view->setTemplatePath($templatePath);
            $this->view->render();
        }

        // If the callback or controller/action returned content, we need to handle it
        if ($returnContent) {
            if ($this->response->getOutput()->acceptsContent($returnContent)) {
                $this->response->setContent($returnContent);
            } else {
                $type   = gettype($returnContent);
                $output = get_class($this->response->getOutput());

                // Stop the output buffer we've started above and throw
                $this->response->stopOutputBuffer();
                throw new \Parable\Framework\Exception(
                    "Route returned value of type '{$type}', which output class '{$output}' cannot handle."
                );
            }
        }

        // Any rendered content was from before the returnContent was set, so we prepend it if there's any
        $renderedContent = $this->response->returnOutputBuffer();
        if ($renderedContent) {
            $this->response->prependContent($renderedContent);
        }

        $this->hook->trigger(self::HOOK_DISPATCH_TEMPLATE_AFTER, $route);
        $this->hook->trigger(self::HOOK_DISPATCH_AFTER, $route);
        return $this;
    }
540857
final public function urlFor($routeName, array $params = array())
    {
        if (null === $this->router) {
            return '';
        }

        return $this->router->urlFor($routeName, $params);
    }
1333386
public function findByRoute(string $route): ?PageInterface
    {
        if (!in_array($route, $this->getCmsRoutes(), true)) {
            return null;
        }

        return $this->repository->findOneByRoute($route);
    }
155551
private static function prepare(Route $route, $params)
    {
        static::$current = $route;

        if ($route->getMethod() == 'resource') {
            if ($route->getTarget()['method'] == 'update') {
                $id = $params[0];
                $params[0] = new Request();
                $params[] = $id;
            } elseif ($route->getTarget()['method'] == 'insert') {
                $params[] = new Request();
            }
            self::treatment(call_user_func_array($route->getClosure(), $params));
        } elseif ($route->getMethod() == 'call') {
            $target = $route->getResource()[$route->name]->getTarget();

            self::treatment(call_user_func_array([$target['controller'], $target['method']], $params));
        } else {
            self::treatment(call_user_func_array($route->getClosure(), $params));
        }
    }
949698
public function createPageRoute(IRouter $routes, string $url): void
	{
		list($presenter, $action) = explode(':', $this->pageLink);

		$routes[] = new Route($url . '[<url .*>]', [
			'presenter' => $presenter,
			'action' => $action,
			null => [
				Route::FILTER_IN => function ($params) {
					if ($this->orm->pages->exists($params['url'])) {
						return $params;
					}
					return null;
				}
			],
		]);
	}
692971
public function toRoute($route = null, $params = array(), $query = array())
    {
        if(!$route)
            return $this->refresh();

        $url = $this->urlFactory->create($route, $params, $query);

        return $this->to($url);
    }
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);
    }
983334
private static function execute(&$route, $params)
    {
        array_shift($params);

        if (static::runAppMiddleware() && static::runRouteMiddleware($route)) {
            static::prepare($route, $params);

            return true;
        }
    }
1218062
final public static function redirectToRoute(
        string $routename,
        array $params = array(),
        bool $domain = true,
        array $query = array(),
        int $status = 302
    ):void {

        $querystring = $domainstring = "";
        $route = self::generateRoute($routename, $params);
        if (!empty($query)) {
            foreach ($query as $one => $value) {
                $querystring .= "$one=$value".(((end($query) !== $value))? "&": "");
            }
            $querystring = "?$querystring";
        }

        if (true === $domain) {
            $server = new GlobalServer();
            $https = ((null !== $server->get("HTTPS") &&
                "on" === $server->get("HTTPS"))? "https://" : "http://");
            $domain = $https.$server->get("HTTP_HOST");
        }
        header("Location: $domain$route$querystring", $status);
        exit(1);
    }
608510
protected function createUrlDefault($route, $params, $ampersand)
    {
        if ($this->urlFormat === self::PATH_FORMAT) {
            $url = rtrim($this->getBaseUrl() . '/' . $route, '/');
            if ($this->appendParams) {
                $url = rtrim($url . '/' . $this->createPathInfo($params, '/', '/'), '/');
                return $route === '' ? $url : $url . $this->urlSuffix;
            } else {
                if ($route !== '') {
                    $url .= $this->urlSuffix;
                }
                $query = $this->createPathInfo($params, '=', $ampersand);
                return $query === '' ? $url : $url . '?' . $query;
            }
        } else {
            $url = $this->getBaseUrl();
            if (!$this->showScriptName) {
                $url .= '/';
            }
            if ($route !== '') {
                $url .= '?' . $this->routeVar . '=' . $route;
                if (($query = $this->createPathInfo($params, '=', $ampersand)) !== '') {
                    $url .= $ampersand . $query;
                }
            } elseif (($query = $this->createPathInfo($params, '=', $ampersand)) !== '') {
                $url .= '?' . $query;
            }
            return $url;
        }
    }
1165717
public function callbackFunction($route = null, $parameters = [])
    {
        if ($route === null || ! is_string($route)) {
            // Gets URI from current request
            $uri = $this->request->getUri();
        } else {
            // Generates URI from '_route'
            $uri = $this->router->generate(
                $route,
                $parameters,
                Router::ABSOLUTE_URL
            );
        }

        $result = parse_url($uri);

        // When uri contains query string
        if (isset($result['query'])) {

            parse_str($result['query'], $query);

            // Remove callback from query
            $query = array_diff_key($query, ['callback' => null]);
        } else {
            // Return unchanged uri
            return $uri;
        }

        return $result['scheme'].'://'.
               (isset($result['user']) ? $result['user'] : '').
               (isset($result['pass']) ? ':'.$result['pass'].'@' : '').
               $result['host'].
               (isset($result['port']) ? ':'.$result['port'] : '').
               (isset($result['path']) ? $result['path'] : '').
               ($query != [] ? '?'.http_build_query($query) : '').
               (isset($result['fragment']) ? '#'.$result['fragment'] : '');
    }
779505
public function callRouteFilter($filter, $parameters, $route, $request, $response = null)
	{
		$data = array_merge(array($route, $request, $response), $parameters);

		return $this->events->until('router.filter: '.$filter, $this->cleanFilterParameters($data));
	}
144189
public function url($route, $params)
    {
        // use array filter to remove keys with null values
        $params += array_filter($this->getEmbedParams());

        return $this->router->generate($route, $params);
    }
175424
public function create(
       string $action,
       string $prefix,
       string $controller,
       array $param,
       string $path): RouteInterface
   {
       try {
           return $this->factory->create(
               $action,
               $prefix,
               $controller,
               $param,
               $path);
       } catch (InvalidArgumentException $e) {
           throw $e;
       }
   }
752809
private function generateUrlForRoute($route, $params)
    {
        $url = $route['uri'];

        while (count($params) > 0) {
            $param = array_shift($params);
            $url = preg_replace('/{.+?}/', $param, $url, 1);
        }

        return $url;
    }