public function testCanConfigureWithArrayInConstructor() { $options = new ListenerOptions(array('cache_dir' => __DIR__, 'config_cache_enabled' => true, 'config_cache_key' => 'foo', 'module_paths' => array('module', 'paths'), 'config_glob_paths' => array('glob', 'paths'), 'config_static_paths' => array('static', 'custom_paths'))); $this->assertSame($options->getCacheDir(), __DIR__); $this->assertTrue($options->getConfigCacheEnabled()); $this->assertNotNull(strstr($options->getConfigCacheFile(), __DIR__)); $this->assertNotNull(strstr($options->getConfigCacheFile(), '.php')); $this->assertSame('foo', $options->getConfigCacheKey()); $this->assertSame(array('module', 'paths'), $options->getModulePaths()); $this->assertSame(array('glob', 'paths'), $options->getConfigGlobPaths()); $this->assertSame(array('static', 'custom_paths'), $options->getConfigStaticPaths()); }
/** * @param ServiceLocatorInterface $serviceLocator * @param Module $module * @return array */ protected function getConfig(ServiceLocatorInterface $serviceLocator, Module $module) { // Load same configs as the ConfigListener would... $applicationConfiguration = $serviceLocator->get('ApplicationConfig'); $listenerOptions = new ListenerOptions($applicationConfiguration['module_listener_options']); $configPaths = array_merge($this->getConfigPaths($listenerOptions->getConfigGlobPaths(), ConfigListener::GLOB_PATH), $this->getConfigPaths($listenerOptions->getConfigStaticPaths(), ConfigListener::STATIC_PATH)); $config = $module->getConfig(); $configs = array(); foreach ($configPaths as $path) { $configs = array_merge($configs, $this->getConfigsByPath($path['path'], $path['type'])); } foreach ($configs as $cfg) { $config = ArrayUtils::merge($config, $cfg); } return $config; }