/**
  * 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;
 }