Commit 3e2bcfdf by Alexander Makarov

Refactored Module::setBasePath to remove instanceof condition

parent e8eccc28
......@@ -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)
......
......@@ -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");
}
......
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