framework/base/Module.php
public function setModules($modules)
    {
        foreach ($modules as $id => $module) {
            $this->_modules[$id] = $module;
        }
    }
public function setModules($modules)
    {
        foreach ($modules as $id => $module) {
            $this->_modules[$id] = $module;
        }
    }
Registers sub-modules in the current module.

Each sub-module should be specified as a name-value pair, where
name refers to the ID of the module and value the module or a configuration
array that can be used to create the module. In the latter case, [[Yii::createObject()]]
will be used to create the module.

If a new sub-module has the same ID as an existing one, the existing one will be overwritten silently.

The following is an example for registering two sub-modules:

```php
[
'comment' => [
'class' => 'app\modules\comment\CommentModule',
'db' => 'db',
],
'booking' => ['class' => 'app\modules\booking\BookingModule'],
]
```

@param array $modules modules (id => module configuration or instances).