Commit e8eccc28 by Alexander Makarov

Refactored instanceof in Module into method in Application

parent 32e36348
......@@ -172,6 +172,20 @@ abstract class Application extends Module
}
/**
* Initializes the application.
* This method is called after the application is created and initialized with property values
* given in configuration.
*/
public function init()
{
$this->preloadComponents();
if ($this->controllerNamespace === null) {
$this->controllerNamespace = 'app\\controllers';
}
}
/**
* Loads components that are declared in [[preload]].
* @throws InvalidConfigException if a component or module to be preloaded is unknown
*/
......
......@@ -167,20 +167,16 @@ abstract class Module extends Component
/**
* Initializes the module.
* This method is called after the module is created and initialized with property values
* given in configuration. The default implement will create a path alias using the module [[id]]
* given in configuration. The default implementation will create a path alias using the module [[id]]
* and then call [[preloadComponents()]] to load components that are declared in [[preload]].
*/
public function init()
{
$this->preloadComponents();
if ($this->controllerNamespace === null) {
if ($this instanceof Application) {
$this->controllerNamespace = 'app\\controllers';
} else {
$class = get_class($this);
if (($pos = strrpos($class, '\\')) !== false) {
$this->controllerNamespace = substr($class, 0, $pos) . '\\controllers';
}
$class = get_class($this);
if (($pos = strrpos($class, '\\')) !== false) {
$this->controllerNamespace = substr($class, 0, $pos) . '\\controllers';
}
}
}
......
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