/**
  *	注册模块路径
  * @param ModuleEvent $e
  */
 public function moduleLoader(ModuleEvent $e)
 {
     $moduleConfig = $e->getModuleConfig();
     /*@var $moduleConfig  \hasscms\module\ModuleConfig */
     foreach ($moduleConfig->getModulePaths() as $alias => $path) {
         \Yii::setAlias($alias, $path);
     }
 }
Beispiel #2
0
 /**
  * Use merged configuration to configure service manager
  *
  * If the merged configuration has a non-empty, array 'container'
  * key, it will be passed to a ServiceManager Config object, and
  * used to configure the service manager.
  *
  * @param ModuleEvent $e
  * @throws Exception\RuntimeException
  * @return void
  */
 public function onLoadModulesPost(ModuleEvent $e)
 {
     $moduleConfig = $e->getModuleConfig();
     $config = $moduleConfig->getMergedConfig(false);
     foreach ($this->containers as $key => $sm) {
         if (isset($config[$sm['config_key']]) && is_array($config[$sm['config_key']]) && !empty($config[$sm['config_key']])) {
             $this->containers[$key]['configuration']['merged_config'] = $config[$sm['config_key']];
         }
         // Merge all of the things!
         $smConfig = array();
         foreach ($this->containers[$key]['configuration'] as $configs) {
             if (isset($configs['configuration_classes'])) {
                 foreach ($configs['configuration_classes'] as $class) {
                     $configs = ArrayHelper::merge($configs, $this->serviceConfigToArray($class));
                 }
             }
             $smConfig = ArrayHelper::merge($smConfig, $configs);
         }
         if (!$sm['container'] instanceof Container) {
             $instance = $this->defaultServiceManager->get($sm['container']);
             if (!$instance instanceof Container) {
                 throw new ErrorException(sprintf('Could not find a valid ServiceManager for %s', $sm['container']));
             }
             $sm['container'] = $instance;
         }
         $this->configureContainer($sm['container'], $smConfig);
     }
 }
Beispiel #3
0
 /**
  * Set the module event
  *
  * @param ModuleEvent $event
  * @return ModuleManager
  */
 public function setEvent(ModuleEvent $event)
 {
     if (!$event->getModuleConfig()) {
         $event->setModuleConfig($this->getConfig());
     }
     $this->event = $event;
     return $this;
 }