Skip to content

Commit

Permalink
Move isWebAliasSetDynamically to RequestTrait, add isWebrootAliasSetD…
Browse files Browse the repository at this point in the history
…ynamically

#3798
  • Loading branch information
brandonkelly committed Feb 8, 2019
1 parent 3fc4bf8 commit e9e4d36
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 16 deletions.
13 changes: 13 additions & 0 deletions src/base/RequestTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,19 @@
*/
trait RequestTrait
{
// Properties
// =========================================================================

/**
* @var bool
*/
public $isWebrootAliasSetDynamically = false;

/**
* @var bool
*/
public $isWebAliasSetDynamically = false;

// Public Methods
// =========================================================================

Expand Down
2 changes: 2 additions & 0 deletions src/console/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,11 @@ public function init()
}
}
Craft::setAlias('@webroot', $dir);
$this->isWebrootAliasSetDynamically = true;
}
if (Craft::getRootAlias('@web') === false) {
Craft::setAlias('@web', '/');
$this->isWebAliasSetDynamically = true;
}
}

Expand Down
18 changes: 2 additions & 16 deletions src/web/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,6 @@ class Request extends \yii\web\Request
*/
private $_actionSegments;

/**
* @var bool
*/
private $_isWebAliasSetDynamically = false;

/**
* @var bool
*/
Expand Down Expand Up @@ -158,10 +153,11 @@ public function init()
// in case a site's base URL requires @web, and so we can include the host info in @web
if (Craft::getRootAlias('@webroot') === false) {
Craft::setAlias('@webroot', dirname($this->getScriptFile()));
$this->isWebrootAliasSetDynamically = true;
}
if (Craft::getRootAlias('@web') === false) {
Craft::setAlias('@web', $this->getHostInfo() . $this->getBaseUrl());
$this->_isWebAliasSetDynamically = true;
$this->isWebAliasSetDynamically = true;
}

$generalConfig = Craft::$app->getConfig()->getGeneral();
Expand Down Expand Up @@ -453,16 +449,6 @@ public function getActionSegments()
return $this->_actionSegments;
}

/**
* Returns whether the `@web` alias is set dynamically.
*
* @return bool Whether the `@web` alias is set dynamically.
*/
public function getIsWebAliasSetDynamically(): bool
{
return $this->_isWebAliasSetDynamically;
}

/**
* Returns whether this is a Live Preview request.
*
Expand Down

0 comments on commit e9e4d36

Please sign in to comment.