Build the URL for given path and parameters.

@param $path
(optional) The path.
@param $params
(optional) The query parameters in associative array.

@return
The URL for the given parameters.
351329
protected function getUri($path = '', $params = array()) {
    $url = $this->getVariable('services_uri') ? $this->getVariable('services_uri') : $this->getVariable('base_uri');

    if (!empty($path))
      if (substr($path, 0, 4) == "http")
        $url = $path;
      else
        $url = rtrim($url, '/') . '/' . ltrim($path, '/');

    if (!empty($params))
      $url .= '?' . http_build_query($params, NULL, '&');

    return $url;
  }
64895
static public function urlWithLtToken($path, $params=[])
    {
        $token = LimitTimeToken::instance()->get($params);
        
        $url = static::url($path, $params);
        
        return static::url($url, ['lt_token' => $token]);
    }
285416
protected function getUrl($route, $params = array())
    {
        $urlHelper = $this->getView()->plugin('url');

        if ('#' === $route[0]) {
            return $route;
        }

        return $urlHelper($route, $params, $this->getRouteOptions());
    }
453711
protected function generateUrl($path, array $parameters = array())
    {
        $ampersand = '&';
        $schema = '';

        return
            \Yii::app()->getRequest()->getHostInfo($schema).
            \Yii::app()->createUrl(trim($path,'/'),$parameters, $ampersand)
        ;
    }
507881
public function put($path, $params = []){
        $json = json_encode($params);
        
        return $this->_call('PUT', $path, $json);
    }
1015973
static function buildForwardUrlGetParams($path, $forward_url_get_params, $remainder)
    {
        $urlpath = findBestLocationInIncludePath($path);

        if ($forward_url_get_params || $remainder) {
            $urlpath .= "?";
        }

        if ($forward_url_get_params) {
            $urlpath .= $forward_url_get_params;
        }

        if ($remainder) {
            $urlpath .= "&";
        }

        if ($remainder) {
            $urlpath .= $remainder;
        }

        return $urlpath;
    }
802040
public function buildUrlWithParameters(array $parameters = [])
    {
        $url = $this->url;

        if (!$this->hasParameters() && !$parameters) {
            return $url;
        }

        foreach ($parameters as $key => $value) {
            $url = str_replace('{' . $key . '}', $value, $url);
        }
        return $url;
    }
1320600
protected function getURL(array $params):string{
		$url = '';

		if($this->scheme){
			$url .= $this->scheme.':';
		}

		if($this->host){
			$url .= '//'.$this->host;

			if($this->port){
				$url .= ':'.$this->port;
			}

		}

		if($this->path){
			$url .= $this->path;
		}

		if(!empty($params)){
			$url .= '?'.http_build_query($params);
		}

		if($this->fragment){
			$url .= '#'.$this->fragment;
		}

		return $url;
	}
1002241
public function createUrl($path = '', $options = array())
    {

        $builtUrl = '';
        $hasHttp = stristr($path, 'http://') || stristr($path, 'https://');

        if (!empty($options['addServer']) && !$hasHttp) {
            $builtUrl .= $this->_server;
        }

        if (!stristr($path, self::URL_PREFIX) && !$hasHttp) {
            $builtUrl .= self::URL_PREFIX . '/' . self::API_VERSION;
        }

        $builtUrl .= $path;

        if (!empty($options['addMethod']) || !empty($options['addToken'])) {
            $builtUrl .= (stristr($path, '?') ? '&' : '?');
        }

        if (!empty($options['addMethod'])) {
            $builtUrl .= '_method=' . $options['addMethod'];
        }
        if (!empty($options['addToken'])) {
            $builtUrl .= ($options['addMethod'] ? '&' : '') . 'access_token=' . $this->_auth->accessToken();
        }

        return $builtUrl;

    }
549059
public function url($path = null)
    {
        $config = $this->make('flarum.config');
        $url = array_get($config, 'url', array_get($_SERVER, 'REQUEST_URI'));

        if (is_array($url)) {
            if (isset($url[$path])) {
                return $url[$path];
            }

            $url = $url['base'];
        }

        if ($path) {
            $url .= '/'.array_get($config, "paths.$path", $path);
        }

        return $url;
    }
211875
public function url($path, array $params = [])
    {
        $base = true;
        if (isset($params['_base'])) {
            $base = $params['_base'];
            unset($params['_base']);
        }
        $url = $this->urlBuilder()->getUrl($path, $params);
        if ($base && strpos($url, 'http') !== 0) {
            $url = $this->request->getAttribute('webroot') . ltrim($url, '/');
        }

        return $url;
    }
119151
public static function get(string $path, array $params = null): string
    {
        self::init();
        $rule = self::$config['dynamic'];
        if (is_callable($rule['path'])) {
            $path = call_user_func_array($rule['path'], [self::$domin, $path, self::$script]);
        }
        //存在get参数
        if ($params && is_callable($rule['query'])) {
            $path .= call_user_func($rule['query'], $params); //get参数
        }
        return $path;
    }
54838
protected function buildUrl($path)
    {
        $baseUrl = $this->getOption('base_url');

        //add trailing slash to the url if not supplied in the base_url setting nor supplied in path #6
        $url = $baseUrl . ((substr($baseUrl, -1) == '/' || substr($path, 0, 1) == '/') ? '' : '/') . $path;

        if (strpos($url, '.json') === false) {
            $url .= '.json';
        }

        return $url;
    }
130788
public static function path($path, $param = [], $add = '')
    {
        Deprecated::method(3.0, UrlGeneratorInterface::class . '::generate');

        $app = AppSingleton::get();

        if (!empty($add) && $add[0] != '?') {
            $add = '?' . $add;
        }

        if (empty($param)) {
            $param = [];
        }

        return $app['url_generator']->generate($path, $param) . $add;
    }
1063185
protected function build_rest_url($url, $params = array()) {
        $base = '';
        if (substr($this->_url, 0, 4) !== 'http') {
            $base .= 'http://';
        }

        $base .= $this->_url;
        if ($this->_port != 80) {
            $base .= ':' . $this->_port;
        }

        $rurl = new \Rapid\URL($base . '/api/' . $url, $params);
        return $rurl->out();
    }
1262510
public function getCachePath($path, array $params = [])
    {
        $sourcePath = $this->getSourcePath($path);

        if ($this->sourcePathPrefix) {
            $sourcePath = substr($sourcePath, strlen($this->sourcePathPrefix) + 1);
        }

        $params = $this->getAllParams($params);
        unset($params['s'], $params['p']);
        ksort($params);

        $md5 = md5($sourcePath.'?'.http_build_query($params));

        $cachedPath = $this->groupCacheInFolders ? $sourcePath.'/'.$md5 : $md5;

        if ($this->cachePathPrefix) {
            $cachedPath = $this->cachePathPrefix.'/'.$cachedPath;
        }
        
        if ($this->cacheWithFileExtensions) {
            $ext = (isset($params['fm']) ? $params['fm'] : pathinfo($path)['extension']);
            $ext = ($ext === 'pjpg') ? 'jpg' : $ext;
            $cachedPath .= '.'.$ext;
        }

        return $cachedPath;
    }
106357
protected function buildUrl($parts, $params)
    {
        $url = '';

        if (isset($parts['host'])) {
            if ($this->isRelativeDomain) {
                $url .= '//'.$parts['host'];
            } else {
                $url .= $parts['scheme'].'://'.$parts['host'];
            }

            if (isset($parts['port'])) {
                $url .= ':'.$parts['port'];
            }
        }

        $url .= $parts['path'];

        if (count($params)) {
            $url .= '?'.http_build_query($params);
        }

        return $url;
    }