コード例 #1
0
 /**
  * Optionally cache merged config
  *
  * This is only attached if config is not cached.
  *
  * @param  ModuleEvent $e
  * @return ConfigListener
  */
 public function onLoadModules(ModuleEvent $e)
 {
     // Trigger MERGE_CONFIG event. This is a hook to allow the merged application config to be
     // modified before it is cached (In particular, allows the removal of config keys)
     $originalEventName = $e->getName();
     $e->setName(ModuleEvent::EVENT_MERGE_CONFIG);
     $e->getTarget()->getEventManager()->triggerEvent($e);
     // Reset event name
     $e->setName($originalEventName);
     // If enabled, update the config cache
     if ($this->getOptions()->getConfigCacheEnabled() && false === $this->skipConfig) {
         $configFile = $this->getOptions()->getConfigCacheFile();
         $this->writeArrayToFile($configFile, $this->getMergedConfig(false));
     }
     return $this;
 }
コード例 #2
0
 /**
  * Load a module with the name
  * @param  ModuleEvent $event
  * @return mixed                            module instance
  * @throws Exception\RuntimeException
  */
 protected function loadModuleByName(ModuleEvent $event)
 {
     $event->setName(ModuleEvent::EVENT_LOAD_MODULE_RESOLVE);
     $result = $this->getEventManager()->triggerEventUntil(function ($r) {
         return is_object($r);
     }, $event);
     $module = $result->last();
     if (!is_object($module)) {
         throw new Exception\RuntimeException(sprintf('Module (%s) could not be initialized.', $event->getModuleName()));
     }
     return $module;
 }