Commit 54e1abaa by Alexander Makarov

Better Module::init refactoring

parent 3e2bcfdf
......@@ -140,6 +140,11 @@ abstract class Application extends Module
$this->registerCoreComponents();
Component::__construct($config);
$this->preloadComponents();
if ($this->controllerNamespace === null) {
$this->controllerNamespace = 'app\\controllers';
}
}
/**
......@@ -172,20 +177,6 @@ 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
*/
......
......@@ -130,6 +130,12 @@ abstract class Module extends Component
$this->id = $id;
$this->module = $parent;
parent::__construct($config);
if ($this->controllerNamespace === null) {
$class = get_class($this);
if (($pos = strrpos($class, '\\')) !== false) {
$this->controllerNamespace = substr($class, 0, $pos) . '\\controllers';
}
}
}
/**
......@@ -173,12 +179,6 @@ abstract class Module extends Component
public function init()
{
$this->preloadComponents();
if ($this->controllerNamespace === null) {
$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