mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-18 07:20:18 +08:00
Merge pull request #2811 from dmeroff/theme_enhancements
Made Theme::basePath optional fixes #2810
This commit is contained in:
@@ -82,13 +82,12 @@ class Theme extends Component
|
|||||||
{
|
{
|
||||||
parent::init();
|
parent::init();
|
||||||
|
|
||||||
if (($basePath = $this->getBasePath()) !== null) {
|
|
||||||
if (empty($this->pathMap)) {
|
if (empty($this->pathMap)) {
|
||||||
$this->pathMap = [Yii::$app->getBasePath() => [$basePath]];
|
if (($basePath = $this->getBasePath()) == null) {
|
||||||
}
|
|
||||||
} else {
|
|
||||||
throw new InvalidConfigException('The "basePath" property must be set.');
|
throw new InvalidConfigException('The "basePath" property must be set.');
|
||||||
}
|
}
|
||||||
|
$this->pathMap = [Yii::$app->getBasePath() => [$basePath]];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private $_baseUrl;
|
private $_baseUrl;
|
||||||
@@ -173,6 +172,7 @@ class Theme extends Component
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts a relative file path into an absolute one using [[basePath]].
|
* Converts a relative file path into an absolute one using [[basePath]].
|
||||||
* @param string $path the relative file path to be converted.
|
* @param string $path the relative file path to be converted.
|
||||||
@@ -180,6 +180,10 @@ class Theme extends Component
|
|||||||
*/
|
*/
|
||||||
public function getPath($path)
|
public function getPath($path)
|
||||||
{
|
{
|
||||||
return $this->getBasePath() . DIRECTORY_SEPARATOR . ltrim($path, '/\\');
|
if (($basePath = $this->getBasePath()) !== null) {
|
||||||
|
return $basePath . DIRECTORY_SEPARATOR . ltrim($path, '/\\');
|
||||||
|
} else {
|
||||||
|
throw new InvalidConfigException('The "basePath" property must be set.');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user