Nette\Http\Url::getBaseUrl PHP Method

getBaseUrl() public method

Returns the base-URI.
public getBaseUrl ( ) : string
return string
    public function getBaseUrl()
    {
        return $this->getHostUrl() . $this->getBasePath();
    }

Usage Example

Example #1
0
 public function constructUrl(Request $appRequest, Url $refUrl)
 {
     // Module prefix not match.
     if ($this->module && !Strings::startsWith($appRequest->getPresenterName(), $this->module)) {
         return null;
     }
     $params = $appRequest->getParameters();
     $urlStack = [];
     // Module prefix
     $moduleFrags = explode(":", Strings::lower($appRequest->getPresenterName()));
     $resourceName = array_pop($moduleFrags);
     $urlStack += $moduleFrags;
     // Resource
     $urlStack[] = Strings::lower($resourceName);
     // Id
     if (isset($params['id']) && is_scalar($params['id'])) {
         $urlStack[] = $params['id'];
         unset($params['id']);
     }
     // Set custom action
     if (isset($params['action']) && $this->_isApiAction($params['action'])) {
         unset($params['action']);
     }
     $url = $refUrl->getBaseUrl() . implode('/', $urlStack);
     // Add query parameters
     if (!empty($params)) {
         $url .= "?" . http_build_query($params);
     }
     return $url;
 }
All Usage Examples Of Nette\Http\Url::getBaseUrl