Generate URL

@param string $name Name of route
@param array $params Parameters of route

@return string
513162
public function url($name, $params = array()) {
		if (!isset($this->namedRoutes[$name])) {
			throw new RouterException("No route matches this name : $name");
		}

		return $this->namedRoutes[$name]->getUrl($params);
	}
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));
        }
    }
63583
public function renderIfExistsArray($name, $params = [])
    {
        if (! $this->exists($name)) {
            return '';
        }

        return $this->renderArray($name, $params);
    }
818528
public function fromRoute($name, array $params = [])
    {
        $router = $this->getRouter();
        $route  = $router->get($name);

        return $route->assemble($params);
    }
1270085
public function generate($name, $parameters = array(), $absolute = false)
    {
        $this->urlGenerator = new UrlGenerator($this->routeCollection, $this->context);

        return $this->urlGenerator->generate($name, $parameters, $absolute);
    }
1228905
public function url($name, array $parameters = [], $schemeRelative = false)
    {
        if ($name instanceof TreeNodeInterface) {
            return $this->router->generate($name, $parameters, $schemeRelative ? UrlGeneratorInterface::NETWORK_PATH : UrlGeneratorInterface::ABSOLUTE_URL);
        } elseif ($name instanceof ContentTreeContext) {
            return $this->router->generate($name->getNode(), $parameters, $schemeRelative ? UrlGeneratorInterface::NETWORK_PATH : UrlGeneratorInterface::ABSOLUTE_URL);
        } elseif ($name instanceof ElementStructureValue) {
            if ($name->getType() === 'link') {
                $link = $name->getValue();
                if ($link['type'] === 'internal' || $link['type'] === 'intrasiteroot') {
                    $tree = $this->contentTreeManager->findByTreeId($link['tid']);
                    if ($tree) {
                        $node = $tree->get($link['tid']);

                        return $this->router->generate($node, $parameters, $schemeRelative ? UrlGeneratorInterface::NETWORK_PATH : UrlGeneratorInterface::ABSOLUTE_URL);
                    }
                } elseif ($link['type'] === 'external') {
                    return $link['url'];
                } elseif ($link['type'] === 'mailto') {
                    return 'mailto:'.$link['recipient'];
                }
            }
        } elseif (is_array($name) && isset($name['type']) && in_array($name['type'], array('internal', 'intrasiteroot', 'external', 'mailto'))) {
            $link = $name;
            if ($link['type'] === 'internal' || $link['type'] === 'intrasiteroot') {
                $tree = $this->contentTreeManager->findByTreeId($link['tid']);
                if ($tree) {
                    $node = $tree->get($link['tid']);

                    return $this->router->generate($node, $parameters, $schemeRelative ? UrlGeneratorInterface::NETWORK_PATH : UrlGeneratorInterface::ABSOLUTE_URL);
                }
            } elseif ($link['type'] === 'external') {
                return $link['url'];
            } elseif ($link['type'] === 'mailto') {
                return 'mailto:'.$link['recipient'];
            }
        } elseif (strlen($name) && (is_int($name) || (int) $name)) {
            $tree = $this->contentTreeManager->findByTreeId((int) $name);
            if ($tree) {
                $node = $tree->get((int) $name);

                return $this->router->generate($node, $parameters, $schemeRelative ? UrlGeneratorInterface::NETWORK_PATH : UrlGeneratorInterface::ABSOLUTE_URL);
            }
        } elseif (is_string($name)) {
            return $this->router->generate($name, $parameters, $schemeRelative ? UrlGeneratorInterface::NETWORK_PATH : UrlGeneratorInterface::ABSOLUTE_URL);
        }

        return '';
    }
1364974
public static function getUrl( $name, $parameters = array(), $schemeRelative = false )
    {
        $serviceContainer = ezpKernel::instance()->getServiceContainer();

        return $serviceContainer->get('router')->generate(
            $name,
            $parameters,
            $schemeRelative ? UrlGeneratorInterface::NETWORK_PATH : UrlGeneratorInterface::ABSOLUTE_URL
        );
    }
1350306
public function capture(string $name, array $params): string
    {
        return $this->make($name)->render($params);
    }
552246
public function generate($routeName, array $params = array())
    {
        // Check if route exists
        if (!isset($this->namedRoutes[$routeName])) {
            throw new Exception("No route with the name $routeName has been found.");
        }

        /** @var \PHPRouter\Route $route */
        $route = $this->namedRoutes[$routeName];
        $url = $route->getUrl();

        // replace route url with given parameters
        if ($params && preg_match_all('/:(\w+)/', $url, $param_keys)) {
            // grab array with matches
            $param_keys = $param_keys[1];

            // loop trough parameter names, store matching value in $params array
            foreach ($param_keys as $key) {
                if (isset($params[$key])) {
                    $url = preg_replace('/:'.preg_quote($key,'/').'/', $params[$key], $url, 1);
                }
            }
        }

        return $url;
    }
634280
public function create($name, $params = [ ])
    {
        if ($name !== null) {
            $name = $this->getName($name);
        } else {
            $name = $this->_base;
        }

        if (!isset($params['rule'])) {
            $params['rule'] = $this->_rule;
        }

        if (!isset($params['class'])) {
            $params['class'] = $this->_class;
        }

        return $this->link($name, $params);
    }
1108532
protected function makeUrl( array$params ):string
	{
		$url= $this->url;

		foreach( $params['path']??[] as $key=>$value )
		{
			$url= str_replace( "{{$key}}", $value, $url );
		}

		if( $params['query']??null )
		{
			$url.= '?'.http_build_query( $params['query'] );
		}

		return $url;
	}
367453
public static function url($name, array $params = null, $protocol = null)
    {
        $route = Route::get($name);
        return $route->isExternal()
            ? $route->uri($params)
            : Url::site($route->uri($params), $protocol);
    }
194497
public function urlFor($routeName, array $params = array())
    {
        $storageKey = md5($routeName . serialize($params));
        if (array_key_exists($storageKey, $this->resolvedUrls)) {
            return $this->resolvedUrls[$storageKey];
        }

        if (!array_key_exists($routeName, $this->routes)) {
            $this->resolvedUrls[$storageKey] = $routeName;
            return $routeName;
        }

        $route = $this->isValidRoute($this->routes[$routeName]);
        if (!$route) {
            $this->resolvedUrls[$storageKey] = $routeName;
            return $routeName;
        }

        $path = $route['path'];
        if (empty($params)) {
            $this->resolvedUrls[$storageKey] = $path;
            return $path;
        }

        foreach ($params as $key => $value) {
            if (is_string($value) || is_int($value)) {
                $path = str_replace('{' . $key . '}', $value, $path);
            }
        }

        $this->resolvedUrls[$storageKey] = $path;

        return $path;
    }
1285946
public function make(Name $name, array $options): string
    {
        $options = (new Map($options))->filter(function ($key, $value) {
            return !$value->isExceptional();
        });

        return $this->url($name, $options);
    }
90558
public function generateUrl($call, array $params = array())
    {
        $url = $this->baseUrl . '/' . $this->version . '/' . $call;
        if (count($params) > 0) {
            $queryString = http_build_query($params, null, '&');
            $queryString = preg_replace('/%5B[0-9]+%5D/simU', '%5B%5D', $queryString);
            $url .= '?' . $queryString;
        }

        return $url;
    }
578931
protected function getUrlConcrete($name, $options)
    {
        try {
            return new UrlConcrete(
                $this->getRouteUri($name),
                $options['lastmod'],
                $options['changefreq'],
                $options['priority']
            );
        } catch (\Exception $e) {
            throw new \InvalidArgumentException(
                sprintf(
                    'Invalid argument for route "%s": %s',
                    $name,
                    $e->getMessage()
                ),
                0,
                $e
            );
        }
    }
1348269
public function getUrl(array $params = [])
    {
        $params = $this->getParams($params);
        $constructedUrl = $this->url;
        if (count($params)) {
            $constructedUrl .= '?';
            foreach ($params as $key => $val) {
                $constructedUrl .= $key . '=' . $val . '&';
            }
            $constructedUrl = substr($constructedUrl, 0, -1);
        }
        return $constructedUrl;
    }