From 3e2bcfdf52c5dd96f349a993ded466d7967bac5e Mon Sep 17 00:00:00 2001 From: Alexander Makarov Date: Sat, 19 Oct 2013 02:19:27 +0400 Subject: [PATCH] Refactored Module::setBasePath to remove instanceof condition --- framework/yii/base/Application.php | 12 ++++++++++++ framework/yii/base/Module.php | 3 --- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/framework/yii/base/Application.php b/framework/yii/base/Application.php index b3803cb..55258ee 100644 --- a/framework/yii/base/Application.php +++ b/framework/yii/base/Application.php @@ -222,6 +222,18 @@ abstract class Application extends Module } /** + * Sets the root directory of the applicaition and the @app alias. + * This method can only be invoked at the beginning of the constructor. + * @param string $path the root directory of the application. + * @throws InvalidParamException if the directory does not exist. + */ + public function setBasePath($path) + { + parent::setBasePath($path); + Yii::setAlias('@app', $this->getBasePath()); + } + + /** * Runs the application. * This is the main entrance of an application. * @return integer the exit status (0 means normal, non-zero values mean abnormal) diff --git a/framework/yii/base/Module.php b/framework/yii/base/Module.php index 8e62d0a..a03fd83 100644 --- a/framework/yii/base/Module.php +++ b/framework/yii/base/Module.php @@ -217,9 +217,6 @@ abstract class Module extends Component $p = realpath($path); if ($p !== false && is_dir($p)) { $this->_basePath = $p; - if ($this instanceof Application) { - Yii::setAlias('@app', $p); - } } else { throw new InvalidParamException("The directory does not exist: $path"); }