Nette\Http\Url::getBasePath PHP Метод

getBasePath() публичный Метод

Returns the base-path.
public getBasePath ( ) : string
Результат string
    public function getBasePath()
    {
        $pos = strrpos($this->path, '/');
        return $pos === FALSE ? '' : substr($this->path, 0, $pos + 1);
    }

Usage Example

 /**
  * Funkce pro doplnění základních parametrů do API
  * @param string $jsonString
  * @return string
  */
 private function replaceJsonVariables($jsonString)
 {
     $link = $this->link('//Default:default');
     $url = new Url($link);
     if (empty($url->host)) {
         $url = $this->getHttpRequest()->getUrl()->hostUrl;
         if (Strings::endsWith($url, '/')) {
             rtrim($url, '/');
         }
         $url .= $link;
         $url = new Url($url);
     }
     $hostUrl = Strings::endsWith($url->getHost(), '/') ? rtrim($url->getHost(), '/') : $url->getHost();
     $basePath = rtrim($url->getBasePath(), '/');
     $paramsArr = ['%VERSION%' => $this->getInstallVersion(), '%BASE_PATH%' => $basePath, '%HOST%' => $hostUrl];
     $arrSearch = [];
     $arrReplace = [];
     foreach ($paramsArr as $key => $value) {
         $arrSearch[] = $key;
         $arrReplace[] = $value;
     }
     return str_replace($arrSearch, $arrReplace, $jsonString);
 }
All Usage Examples Of Nette\Http\Url::getBasePath