From b3053f4346d1537b14342f5861c9d8efd1871a14 Mon Sep 17 00:00:00 2001 From: Dmitry Erofeev Date: Wed, 19 Mar 2014 15:40:20 +0400 Subject: [PATCH 1/3] Made Theme::basePath optional fixes #2810 --- framework/base/Theme.php | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/framework/base/Theme.php b/framework/base/Theme.php index 5d3d55cf5c..9e1141f444 100644 --- a/framework/base/Theme.php +++ b/framework/base/Theme.php @@ -82,12 +82,11 @@ class Theme extends Component { parent::init(); - if (($basePath = $this->getBasePath()) !== null) { - if (empty($this->pathMap)) { - $this->pathMap = [Yii::$app->getBasePath() => [$basePath]]; + if (empty($this->pathMap)) { + if (($basePath = $this->getBasePath()) == null) { + throw new InvalidConfigException('The "basePath" property must be set.'); } - } else { - throw new InvalidConfigException('The "basePath" property must be set.'); + $this->pathMap = [Yii::$app->getBasePath() => [$basePath]]; } } @@ -172,14 +171,4 @@ class Theme extends Component throw new InvalidConfigException('The "baseUrl" property must be set.'); } } - - /** - * Converts a relative file path into an absolute one using [[basePath]]. - * @param string $path the relative file path to be converted. - * @return string the absolute file path - */ - public function getPath($path) - { - return $this->getBasePath() . DIRECTORY_SEPARATOR . ltrim($path, '/\\'); - } } From ac0a56e9d0d6ad4bbad22358f4baa69214db618e Mon Sep 17 00:00:00 2001 From: Dmitry Erofeev Date: Wed, 19 Mar 2014 16:29:59 +0400 Subject: [PATCH 2/3] reverted deletion of Theme::getPath() --- framework/base/Theme.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/framework/base/Theme.php b/framework/base/Theme.php index 9e1141f444..fbdb822215 100644 --- a/framework/base/Theme.php +++ b/framework/base/Theme.php @@ -171,4 +171,15 @@ class Theme extends Component throw new InvalidConfigException('The "baseUrl" property must be set.'); } } + + + /** + * Converts a relative file path into an absolute one using [[basePath]]. + * @param string $path the relative file path to be converted. + * @return string the absolute file path + */ + public function getPath($path) + { + return $this->getBasePath() . DIRECTORY_SEPARATOR . ltrim($path, '/\\'); + } } From 0fa8f8cc0179ddd00589d9660330df64c362f667 Mon Sep 17 00:00:00 2001 From: Dmitry Erofeev Date: Wed, 19 Mar 2014 16:53:35 +0400 Subject: [PATCH 3/3] fixed Theme::getPath() --- framework/base/Theme.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/framework/base/Theme.php b/framework/base/Theme.php index fbdb822215..6fe4955a29 100644 --- a/framework/base/Theme.php +++ b/framework/base/Theme.php @@ -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.'); + } } }