Back to Router class

Method createUri

protected \Joomla\CMS\Uri\Uri
createUri
(mixed $url)
Create a uri based on a full or partial URL string
Parameters
  • string $url The URI or an associative array
Returns
  • \Joomla\CMS\Uri\Uri
Since
  • 3.2
Class: Router
Project: Joomla

Method createUri - Source code

/**
 * Create a uri based on a full or partial URL string
 *
 * @param   string  $url  The URI or an associative array
 *
 * @return  Uri
 *
 * @since   3.2
 */
protected function createUri($url)
{
    if (!\is_array($url) && substr($url, 0, 1) !== '&') {
        return new Uri($url);
    }
    $uri = new Uri('index.php');
    if (\is_string($url)) {
        $vars = array();
        if (strpos($url, '&') !== false) {
            $url = str_replace('&', '&', $url);
        }
        parse_str($url, $vars);
    } else {
        $vars = $url;
    }
    $vars = array_merge($this->getVars(), $vars);
    foreach ($vars as $key => $var) {
        if ($var == '') {
            unset($vars[$key]);
        }
    }
    $uri->setQuery($vars);
    return $uri;
}