Merge pull request #2811 from dmeroff/theme_enhancements

Made Theme::basePath optional fixes #2810
This commit is contained in:
Qiang Xue
2014-03-19 09:28:35 -04:00

View File

@@ -82,12 +82,11 @@ class Theme extends Component
{ {
parent::init(); parent::init();
if (($basePath = $this->getBasePath()) !== null) { if (empty($this->pathMap)) {
if (empty($this->pathMap)) { if (($basePath = $this->getBasePath()) == null) {
$this->pathMap = [Yii::$app->getBasePath() => [$basePath]]; throw new InvalidConfigException('The "basePath" property must be set.');
} }
} else { $this->pathMap = [Yii::$app->getBasePath() => [$basePath]];
throw new InvalidConfigException('The "basePath" property must be set.');
} }
} }
@@ -173,13 +172,18 @@ 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.
* @return string the absolute file path * @return string the absolute file path
*/ */
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.');
}
} }
} }