private function setupConfig(\Silex\Application $app, $configName)
 {
     $app[$configName . '.manager'] = $app->share(function ($app) {
         return new ConfigManager();
     });
     $app[$configName] = $app->share(function ($app) use($configName) {
         // Get the config paths and the file locator.
         $paths = $app[$configName . '.paths'];
         if (null === $paths || count($paths) === 0) {
             throw ConfigException::pathsNotSpecified();
         }
         $locator = new FileLocator($paths);
         // Dispatch the event so that other providers can add their
         // definitions.
         $this->dispatchInitEvent($app);
         // Get some app definitions.
         $cacheType = $app[$this->configName . '.cache.type'];
         $manager = $app[$configName . '.manager'];
         $loaderFactory = new LoaderFactory($locator, $manager->getLoaders());
         $cacheFactory = new CacheProducer($manager->getCacheFactories(), $app, $cacheType);
         $processor = new Processor();
         $compiler = new ConfigCompiler($manager, $loaderFactory, $processor, $cacheFactory);
         // Run the configuration compiler.
         $config = new Config($compiler->compile());
         $this->dispatchLoadedEvent($app, $config);
         return $config;
     });
 }