Commit 62fae9c1 by Qiang Xue

Merge pull request #2811 from dmeroff/theme_enhancements

Made Theme::basePath optional fixes #2810
parents 30d84ffb 0fa8f8cc
......@@ -82,13 +82,12 @@ class Theme extends Component
{
parent::init();
if (($basePath = $this->getBasePath()) !== null) {
if (empty($this->pathMap)) {
$this->pathMap = [Yii::$app->getBasePath() => [$basePath]];
}
} else {
if (($basePath = $this->getBasePath()) == null) {
throw new InvalidConfigException('The "basePath" property must be set.');
}
$this->pathMap = [Yii::$app->getBasePath() => [$basePath]];
}
}
private $_baseUrl;
......@@ -173,6 +172,7 @@ class Theme extends Component
}
}
/**
* Converts a relative file path into an absolute one using [[basePath]].
* @param string $path the relative file path to be converted.
......@@ -180,6 +180,10 @@ class Theme extends Component
*/
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.');
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment