Browse Source

Refactored Module::setBasePath to remove instanceof condition

tags/2.0.0-beta
Alexander Makarov 11 years ago
parent
commit
3e2bcfdf52
  1. 12
      framework/yii/base/Application.php
  2. 3
      framework/yii/base/Module.php

12
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. * Runs the application.
* This is the main entrance of an application. * This is the main entrance of an application.
* @return integer the exit status (0 means normal, non-zero values mean abnormal) * @return integer the exit status (0 means normal, non-zero values mean abnormal)

3
framework/yii/base/Module.php

@ -217,9 +217,6 @@ abstract class Module extends Component
$p = realpath($path); $p = realpath($path);
if ($p !== false && is_dir($p)) { if ($p !== false && is_dir($p)) {
$this->_basePath = $p; $this->_basePath = $p;
if ($this instanceof Application) {
Yii::setAlias('@app', $p);
}
} else { } else {
throw new InvalidParamException("The directory does not exist: $path"); throw new InvalidParamException("The directory does not exist: $path");
} }

Loading…
Cancel
Save