Commit 710e70b8 by Qiang Xue

Fixes #2037: Dropped the support for using `yii\base\Module` as concrete module classes

parent 161e3ab3
......@@ -29,7 +29,7 @@ forum/
### Module Classes <a name="module-classes"></a>
Each module should have a module class which extends from [[yii\base\Module]]. The class should be located
Each module should have a unique module class which extends from [[yii\base\Module]]. The class should be located
directly under the module's [[yii\base\Module::basePath|base path]] and should be [autoloadable](concept-autoloading.md).
When a module is being accessed, a single instance of the corresponding module class will be created.
Like [application instances](structure-applications.md), module instances are used to share data and components
......@@ -173,7 +173,7 @@ different from the one created by Yii in response to a request.
You may also access the instance of a module using the following approaches:
```php
// get the module whose ID is "forum"
// get the child module whose ID is "forum"
$module = \Yii::$app->getModule('forum');
// get the module to which the currently requested controller belongs
......@@ -239,6 +239,10 @@ For a controller within a nested module, its route should include the IDs of all
For example, the route `forum/admin/dashboard/index` represents the `index` action of the `dashboard` controller
in the `admin` module which is a child module of the `forum` module.
> Info: The [[yii\base\Module::getModule()|getModule()]] method only returns the child module directly belonging
to its parent. The [[yii\base\Application::loadedModules]] property keeps a list of loaded modules, including both
direct children and nested ones, indexed by their class names.
## Best Practices <a name="best-practices"></a>
......
......@@ -9,6 +9,7 @@ Yii Framework 2 Change Log
- Bug: Date and time formatting now assumes UTC as the timezone for input dates unless a timezone is explicitly given (cebe)
- Enh #4275: Added `removeChildren()` to `yii\rbac\ManagerInterface` and implementations (samdark)
- Enh: Added `yii\base\Application::loadedModules` (qiangxue)
- Chg #2037: Dropped the support for using `yii\base\Module` as concrete module classes (qiangxue)
2.0.0-rc September 27, 2014
......
......@@ -350,9 +350,6 @@ class Module extends ServiceLocator
return $this->_modules[$id];
} elseif ($load) {
Yii::trace("Loading module: $id", __METHOD__);
if (is_array($this->_modules[$id]) && !isset($this->_modules[$id]['class'])) {
$this->_modules[$id]['class'] = 'yii\base\Module';
}
/* @var $module Module */
$module = Yii::createObject($this->_modules[$id], [$id, $this]);
$module->setInstance($module);
......
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