Generates a URL based on a route.

@param string $route

@return string|bool The generated URL or false on failure.
@throws \Xloit\Bridge\Zend\Uri\Exception\RuntimeException
502990
protected function generateRouteUrl($route = null)
    {
        if (null === $route || strpos($route, '/') !== 0) {
            return $route;
        }

        if (null === $this->getRouteMatch()) {
            throw new Exception\RuntimeException('No RouteMatch instance provided');
        }

        $routeName = $this->getRouteMatch()->getMatchedRouteName();

        if ($routeName === null) {
            throw new Exception\RuntimeException('RouteMatch does not contain a matched route name');
        }

        $position = strpos($routeName, '/');

        if ($position !== false) {
            /**
             * If we request the name /, it will mean that we need to only get
             * the root part of the route without any other module route params
             */
            if ('/' === $route) {
                $results = substr($routeName, 0, $position);
            } else {
                $results = substr($routeName, 0, $position) . $route;
            }
        } else {
            if ('/' === $route) {
                $results = $routeName;
            } else {
                $results = $routeName . $route;
            }
        }

        return $results;
    }
831675
public function getLink($route)
    {
        $token = 'token';
        $secure = true;
        return $this->url->link($route, $token . '=' . $this->session->data[$token], $secure);
    }
1029438
final protected function redirectToRoute($route)
    {
        $url = $this->urlBuilder->build($route);

        if ($url !== null) {
            $this->response->redirect($url);
        } else {
            throw new RuntimeException(sprintf('Unknown route supplied for redirection "%s"', $route));
        }
    }
136802
private function getRoute(string $routeName): Route
    {
        foreach ($this->router->getRouteCollection() as $name => $route) {
            if ($routeName === $name) {
                return $route;
            }
        }

        throw new RuntimeException(sprintf('The route "%s" does not exist.', $routeName));
    }
1131359
public static function performRoute($route) {
		$api_mode = isset($route["api-mode"]);
		Request::setRequestVariables($route["variables"], $api_mode);

		$controller = new $route["class"];
		$response = $controller->$route["method"]();

		if(!Request::isAjax() && !Request::isAPI() && isset($route["render-path"])) {
			Request::setRenderPath($route["render-path"]);
			try {
				$route = self::findRoute(explode('/', $route["render-path"]));
			} catch(ValidRouteNotFoundException $e) {
				throw new ValidRenderRouteNotFoundException($e);
			}
			$response = self::performRoute($route);
		}

		return $response;
	}
433932
private static function runRouteMiddleware($route)
    {
        $routeMiddleware = Filter::$routeMiddleware;

        if (!is_null($route->getMiddleware())) {
            // if ($route->getMiddleware()['type'] == 'route' && ! is_null($route->getMiddleware()['middlewares'])) {
            foreach ($route->getMiddleware() as $middleware) {
                //Check if the routes middlewares are in filter class
                exception_if(!array_has($routeMiddleware, $middleware), RouteMiddlewareNotFoundException::class, $middleware);

                $middleware = instance($routeMiddleware[$middleware]);

                $middleware->handle(new Request());
            }
        }

        return true;
    }
893930
protected function generateLink($route, $params = null)
    {
        if ($route instanceof Closure) {
            // Have to stringify this before calling Route::has because it will
            // Fail if we don't pass a string in
            $route = $this->stringify($route);
        }
        if (\Route::has($route)) {
            // If params is empty, just don't call it...
            if (empty($params)) {
                return route($this->routify($route));
            } else { // Since $params isn't empty and $route is a Route, just paramify both.
                return route($this->routify($route), $this->routeparamify($params));
            }
        }

        if (empty($params)) {
            return url($this->routify($route));
        } else {
            // Since $params isn't empty and $route is not Route, just paramify both anyway.
            return url($this->routify($route), $this->routeparamify($params));
        }
    }
217671
public function url( $path )
	{
		$adapter = $this->driver->getAdapter();

		if ( $adapter instanceof AwsS3Adapter )
		{
			$path = $adapter->getPathPrefix() . $path;

			return $adapter->getClient()->getObjectUrl( $adapter->getBucket(), $path );
		}
		elseif ( $adapter instanceof LocalAdapter )
		{
			return '/storage/' . $path;
		}
		elseif ( method_exists( $adapter, 'getUrl' ) )
		{
			return $adapter->getUrl( $path );
		}
		else
		{
			throw new RuntimeException( 'This driver does not support retrieving URLs.' );
		}
	}
516169
protected function getRouteResource($route)
	{
		if (!config('openapischemas.resource_tag')) {
			$this->parentCommand->error('The "resource_tag" value in your apischemas.php configuration file must defined.');
			exit();
		}
		$routeAction = $route->getAction();
		list($class, $method) = explode('@', $routeAction['uses']);
		$reflection = new ReflectionClass($class);

		$comment = $reflection->getDocComment();
		if ($comment) {
			$docBlock = $this->docBlockFactory->create($comment);
			foreach ($docBlock->getTags() as $tag) {
				if ($tag->getName() === config('openapischemas.resource_tag')) {
					return $tag->getDescription()->render();
				}
			}
		}

		return null;
	}
389972
public static function url($route = '', Array $params = [])
    {
        $dir = dirname($_SERVER['PHP_SELF']);
        $dir = $dir == DIRECTORY_SEPARATOR ? '':$dir;
        $scheme = isset($_SERVER['HTTPS']) && 'on' === $_SERVER['HTTPS'] ? 'https':'http';
        $baseUrl = $scheme.'://'.$_SERVER['HTTP_HOST'].$dir.'/?r='.$route;
        return empty($params) ? $baseUrl : $baseUrl . '&' . http_build_query($params);
    }
163273
private function createResponse($route): ?Response
    {
        $controller = $this->getRouteControllerInstance($route);
        if (!is_null($controller)) {
            $responseBefore = $controller->before();
            if ($responseBefore instanceof Response) {
                return $responseBefore;
            }
        }

        $values = $route['route']->getArguments($this->requestedUri);
        $this->loadRequestParameters($values);
        $callback = new Callback($route['callback']);
        $arguments = $this->getFunctionArguments($callback->getReflection(), array_values($values));
        $response = $callback->executeArray($arguments);

        if (!is_null($controller)) {
            $responseAfter = $controller->after($response);
            if ($responseAfter instanceof Response) {
                return $responseAfter;
            }
        }
        return $response;
    }
22134
public function getRoute($route = '', $fqr = true)
    {
        if (strpos($route, 'index.php?') === false) {
            $route .= 'index.php?'.$route;
        }

        return $this->getService('com:application')->getRouter()->build($route, $fqr);
    }
1364623
public static function transRouteExternal($route) {
        $app = app();
        $locale = \Sirgrimorum\CrudGenerator\CrudGenerator::setLocale();
        //$locale = $app->getLocale();
        $transroute = $app->translator->trans($route, [], $locale);
        return $transroute;
    }
1029571
public function getUrl($page)
    {
        if (is_null($this->url)) {
            throw new RuntimeException('URL template must be defined');
        }

        if (strpos($this->url, $this->placeholder) !== false) {
            return str_replace($this->placeholder, $page, $this->url);
        } else {
            // Without placeholder, no substitution is done, therefore pagination links won't work
            throw new LogicException('The URL string must contain at least one placeholder to make pagination links work');
        }
    }
970717
protected static function dynamic($route)
    {
        $parms = [];
        $param = '';
        $open = false;
        //
        for ($i = 0; $i < Strings::length($route); $i++) {
            if ($open && $route[$i] != '}') {
                $param .= $route[$i];
            }
            //
            if ($route[$i] == '{' && !$open) {
                $open = true;
            } //
            elseif ($route[$i] == '}' && $open) {
                $open = !true;
                $parms[] = $param;
                $param = '';
            }
        }
        //
        return $parms;
    }
712680
protected function generateUrl($path)
    {
        $url = $path;
        if ($this->hostPrefix) {
            // url should start with a /
            $url = $this->hostPrefix . $url;
        }

        return $url;
    }
1246941
protected function toRegex($route)
    {
        $path = $this->quote($route);

        return preg_replace_callback(
            '~\<(?<key>[\w-]+)\>~',
            function ($matches)
            {
                return '(?<' . $matches['key'] . '>' . ($this->regex[$matches['key']] ?? $this->defaultRegex) . ')';
            },
            $path
        );
    }