yii\web\UrlManager::getBaseUrl PHP Метод

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

It defaults to [[Request::baseUrl]]. This is mainly used when [[enablePrettyUrl]] is true and [[showScriptName]] is false.
public getBaseUrl ( ) : string
Результат string the base URL that is used by [[createUrl()]] to prepend to created URLs.
    public function getBaseUrl()
    {
        if ($this->_baseUrl === null) {
            $request = Yii::$app->getRequest();
            if ($request instanceof Request) {
                $this->_baseUrl = $request->getBaseUrl();
            } else {
                throw new InvalidConfigException('Please configure UrlManager::baseUrl correctly as you are running a console application.');
            }
        }
        return $this->_baseUrl;
    }

Usage Example

Пример #1
0
 /**
  * @inheritdoc
  */
 public function getBaseUrl()
 {
     return parent::getBaseUrl() . ($this->_language != Yii::$app->language || $this->_language != Yii::$app->request->getDefaultLanguage() ? '/' . $this->_language : '');
 }
All Usage Examples Of yii\web\UrlManager::getBaseUrl