Generate the complete URL of a link.

@param array  $parameters   The link parameters (go to LinkTrait to have the list)
@param string $avoidRefresh Do we have to refresh or not ?
@param array  $url          Fallback url

@return string
13908
public function victoireLinkUrl($parameters, $avoidRefresh = true, $url = '#')
    {
        $referenceType = isset($parameters['referenceType']) ? $parameters['referenceType'] : UrlGeneratorInterface::ABSOLUTE_PATH;
        if (!isset($parameters['locale'])) {
            if ($this->request) {
                $parameters['locale'] = $this->request->getLocale();
            } else {
                $parameters['locale'] = $this->defaultLocale;
            }
        }

        $viewReference = isset($parameters['viewReference']) ? $parameters['viewReference'] : null;
        switch ($parameters['linkType']) {
            case Link::TYPE_VIEW_REFERENCE:
                if ($viewReference instanceof ViewReference) {
                    $viewReference = $viewReference->getId();
                }
                $linkUrl = '';
                if (!empty($parameters['viewReferencePage'])) {
                    $page = $parameters['viewReferencePage'];
                } else {
                    $params = [
                        'id'     => $viewReference,
                        'locale' => $parameters['locale'],
                    ];

                    try {
                        $page = $this->pageHelper->findPageByParameters($params);
                    } catch (ViewReferenceNotFoundException $e) {
                        $this->logger->error($e->getMessage(), $params);
                        /** @var ErrorPage $page */
                        $page = $this->errorPageRepository->findOneByCode(404);
                        $linkUrl = $this->router->generate(
                            'victoire_core_page_show',
                            array_merge([
                            '_locale' => $parameters['locale'],
                            'url'     => $page->getSlug(),
                        ], $params)
                        );
                    }
                }

                if ($page instanceof WebViewInterface) {
                    $linkUrl = $this->router->generate(
                        'victoire_core_page_show',
                        [
                            '_locale' => $parameters['locale'],
                            'url'     => $page->getReference($parameters['locale'])->getUrl(),
                        ],
                        $referenceType
                    );
                }

                if (!$this->request || ($this->request && $this->request->getRequestUri() !== $linkUrl) || !$avoidRefresh) {
                    $url = $linkUrl;
                }
                break;
            case Link::TYPE_ROUTE:
                $url = $this->router->generate($parameters['route'], $parameters['routeParameters'], $referenceType);
                break;
            case Link::TYPE_WIDGET:
                $attachedWidget = $parameters[Link::TYPE_WIDGET];
                $url = '';

                if ($attachedWidget) {
                    //If Widget's View has an url and Widget is not in the current View, add this url in the link
                    if (method_exists($attachedWidget->getWidgetMap()->getView(), 'getUrl')
                        && (!$this->request || rtrim($this->request->getRequestUri(), '/') != rtrim($url, '/'))) {
                        /** @var View $view */
                        $view = $attachedWidget->getWidgetMap()->getView();
                        /* @var Widget $attachedWidget */
                        $locale = $attachedWidget->getLocale($this->request ? $this->request->getLocale() : $this->defaultLocale);
                        $view->translate($locale);
                        $url .= $this->router->generate('victoire_core_page_show', ['_locale' => $locale, 'url' => $view->getUrl()], $referenceType);
                    }

                    //Add anchor part
                    $url .= '#widget-'.$attachedWidget->getId();
                }

                break;
            default:
                $url = $parameters['url'];
        }

        return $url;
    }
1273418
protected function getCustomUrl(array $urlParameters = array())
    {
        $urlParameters = $this->addRequestVariablesToUrlParameters($urlParameters);

        if ($this->customUrl && count($urlParameters) > 0)
        {
            $params = http_build_query($urlParameters);

            if ('' != parse_url($this->customUrl, PHP_URL_QUERY))
            {
                // existing query string, append
                return $this->customUrl.'&'.$params;
            }

            return $this->customUrl.'?'.$params;
        }

        return $this->customUrl;
    }
91924
public function getCurrentUrl(array $options)
    {
        $url = Environment::get('url');

        if (isset($options['skipParams']) && $options['skipParams']) {
            $url .= parse_url(Environment::get('uri'), PHP_URL_PATH);
        } else {
            $url .= Environment::get('requestUri');
        }

        return $url;
    }
787353
public function redirect($url, $args = [])
    {
        if (isset($args['time'])) {
            $this->header('Refresh', $args['time'] . ';url=' . $url);
        } else if (isset($args['httpCode'])) {
            $this->header('Location', $url, true, $args['httpCode']);
        } else {
            $this->header('Location', $url, true, 302);
        }
        return '';
    }
1344329
private function getMetaRefreshURL($url, $html)
    {
        if ('' === $html) {
            return false;
        }

        // <meta HTTP-EQUIV="REFRESH" content="0; url=http://www.bernama.com/bernama/v6/newsindex.php?id=943513">
        if (!preg_match('!<meta http-equiv=["\']?refresh["\']? content=["\']?[0-9];\s*url=["\']?([^"\'>]+)["\']?!i', $html, $match)) {
            return false;
        }

        $redirectUrl = str_replace('&amp;', '&', trim($match[1]));
        if (preg_match('!^https?://!i', $redirectUrl)) {
            // already absolute
            $this->logger->info('Meta refresh redirect found (http-equiv="refresh"), new URL: ' . $redirectUrl);

            return $redirectUrl;
        }

        // absolutize redirect URL
        $base = new \SimplePie_IRI($url);
        // remove '//' in URL path (causes URLs not to resolve properly)
        if (isset($base->ipath)) {
            $base->ipath = str_replace('//', '/', $base->ipath);
        }

        if ($absolute = \SimplePie_IRI::absolutize($base, $redirectUrl)) {
            $this->logger->info('Meta refresh redirect found (http-equiv="refresh"), new URL: ' . $absolute);

            return $absolute->get_iri();
        }

        return false;
    }
1328561
protected function doRefresh($url)
    {
        if ($this->app->core->router->isAjax()) {
            $cmd = $this->ajax->createActCommand();

            $cmd->setFunction('refresh');
            $cmd->setArgs($url);

            $this->ajax->addCommand($cmd);
        }
        else {
            $this->redirectExit($url);
        }
    }
455520
public function updateURLWithParameters($url, array $params)
    {
        if (empty($params)) {
            return $url;
        }

        $parts = parse_url($url);

        $scheme = isset($parts['scheme']) ? $parts['scheme'] : null;
        if ($scheme) {
            $scheme .= ':';
        }

        $host = isset($parts['host']) ? $parts['host'] : null;
        if ($host) {
            $host = "//$host";
        }
        $path = isset($parts['path']) ? $parts['path'] : null;

        //Merge parameters
        $query = isset($parts['query']) ? $parts['query'] : null;
        $params += $this->getParameterFromQuery($query);
        if (!empty($params)) {
            $query = '?' . http_build_query($params);
        }

        $fragment = isset($parts['fragment']) ? $parts['fragment'] : null;
        if ($fragment) {
            $fragment = "#$fragment";
        }

        return "{$scheme}{$host}{$path}{$query}$fragment";
    }
520698
private function rawRequest($url, $parameters = [])
    {
        $request = new OAuth2Request($this->oauth2);

        $request->setUrl($url);
        $request->setParams($parameters);

        return $request->executeRequest();
    }
248596
private function buildUrl(array $url, array $params = array())
    {
        ksort($params);
        $url['query'] = http_build_query($params, '', '&');

        $scheme   = isset($url['scheme']) ? $url['scheme'].'://' : '';
        $host     = isset($url['host']) ? $url['host'] : '';
        $port     = isset($url['port']) ? ':'.$url['port'] : '';
        $user     = isset($url['user']) ? $url['user'] : '';
        $pass     = isset($url['pass']) ? ':'.$url['pass']  : '';
        $pass     = ($user || $pass) ? $pass . '@' : '';
        $path     = isset($url['path']) ? $url['path'] : '';
        $query    = isset($url['query']) && $url['query'] ? '?'.$url['query'] : '';
        $fragment = isset($url['fragment']) ? '#'.$url['fragment'] : '';

        return $scheme.$user.$pass.$host.$port.$path.$query.$fragment;
    }
89144
public function formatUrl(array $parameters = []): string
    {
        $values = [];

        foreach ($this->parameterNames as $name) {
            if (!isset($parameters[$name])) {
                throw new \InvalidArgumentException("Missing route parameter '$name'");
            }

            $values[] = rawurlencode($parameters[$name]);
            unset($parameters[$name]);
        }

        if (!empty($parameters)) {
            throw new \InvalidArgumentException(
                'Unexpected route parameters: ' . implode(', ', array_keys($parameters))
            );
        }

        return vsprintf($this->format, $values);
    }
827184
final public function buildUrl(string $url, array $parameters = []) : string
    {
        if (! $this->builder) {
            throw new \RuntimeException('No URL builder has been registered');
        }

        return $this->builder->buildUrl($url, $parameters);
    }
288921
public function createUrl(array $parameters = array())
    {
        $final_parameters = $this->getFinalParameters();
        $path = $this->getBaseURL();

        // Override default parameters
        $final_parameters = array_merge($final_parameters, $parameters);

        return $path . "?" . http_build_query($final_parameters, null, '&') . $this->buildFragment();
    }
30061
protected function appendRedirectableGetParameters($url)
    {
        $concat = (parse_url($url, PHP_URL_QUERY) === null)
            ? '?'
            : '&';

        return
            $url . (
            $this->settingsManager->getRedirectableGetParameters()
                ? $concat . $this->settingsManager->getRedirectableGetParameters()
                : ''
            );
    }
507470
public function getAbsoluteUrl(array $params = array())
	{
		if ( !is_object($this->urlBuilder) ) {
			throw new PageException(
				'The url builder of a page not set, have you used @page-url annotation?',
				PageException::TYPE_MISSING_URL_BUILDER
			);
		}

		return $this->urlBuilder->build($params);
	}
1157194
public function url($url, ...$parameters)
    {
        $this->link_type = self::LINK_URL;
        $this->link_value = [$url, $parameters];
        $this->checkActive();

        return $this;
    }
729850
final protected function getReloadResponse($removeParameters = [])
    {
        $url = $this->request()->getUrl($removeParameters);
        return $this->getRedirectUrlResponse($url);
    }
1211752
protected function generateStandardUrl(array $urlParameters = array(), $absolute = false)
    {
        $urlParameters = $this->addRequestVariablesToUrlParameters($urlParameters);

        $anchor = '';
        if ($this->hasAnchor())
        {
            $anchor = '#'.$this->getAnchor();
        }

        return $this->getRouter()->generate($this->getRouteName(), $urlParameters, $absolute) . $anchor;
    }