Ejemplo n.º 1
0
 /**
  * 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;
 }
Ejemplo n.º 2
0
 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;
     }
 }
Ejemplo n.º 3
0
 /**
  * 向app注册引导事件,在请求前,由于默认模块和组件可能会重名所以定义这个事件
  * @param ModuleEvent $e
  */
 public function onBootstrap(ModuleEvent $e)
 {
     $module = $e->getModule();
     if (!$module instanceof BootstrapListenerInterface && !method_exists($module, 'onBootstrap')) {
         return;
     }
     $moduleManager = $e->getTarget();
     Event::on($this->appClass, $this->appBootstarpEventName, array($module, 'onBootstrap'));
 }