/** * Merge the config for each module * * @param ModuleEvent $e * @return ConfigListener */ public function onLoadModule(ModuleEvent $e) { $module = $e->getModule(); if (!$module instanceof ConfigProviderInterface && !is_callable(array($module, 'getConfig'))) { return $this; } $config = $module->getConfig(); $this->addConfig($e->getModuleName(), $config); return $this; }
public function onLoadModule(ModuleEvent $e) { $module = $e->getModule(); foreach ($this->containers as $key => $sm) { if (!$module instanceof $sm['module_class_interface'] && !method_exists($module, $sm['module_class_method'])) { continue; } $config = $module->{$sm['module_class_method']}(); if (!is_array($config)) { // If we don't have an array by this point, nothing left to do. continue; } // We're keeping track of which modules provided which configuration to which service managers. // The actual merging takes place later. Doing it this way will enable us to provide more powerful // debugging tools for showing which modules overrode what. $fullname = $e->getModuleName() . '::' . $sm['module_class_method'] . '()'; $this->containers[$key]['configuration'][$fullname] = $config; } }
/** * 实例化模块 * @param ModuleEvent $e */ public function moduleResolver(ModuleEvent $e) { $module = \Yii::$app->getModule($e->getModuleName()); $e->setModule($module); }