enable dumping of config

This commit is contained in:
Kevin Bond 2014-04-08 14:41:46 -04:00
parent ae598e6114
commit ef57204cd5

View File

@ -28,21 +28,15 @@ class KnpGaufretteExtension extends Extension
public function load(array $configs, ContainerBuilder $container) public function load(array $configs, ContainerBuilder $container)
{ {
$processor = new Processor(); $processor = new Processor();
$config = $processor->processConfiguration($this->getConfiguration($configs, $container), $configs);
// first assemble the adapter factories
$factoryConfig = new FactoryConfiguration();
$config = $processor->processConfiguration($factoryConfig, $configs);
$factories = $this->createAdapterFactories($config, $container);
// then normalize the configs
$mainConfig = new MainConfiguration($factories);
$config = $processor->processConfiguration($mainConfig, $configs);
$loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); $loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader->load('gaufrette.xml'); $loader->load('gaufrette.xml');
$adapters = array();
foreach ($config['adapters'] as $name => $adapter) { foreach ($config['adapters'] as $name => $adapter) {
$adapters[$name] = $this->createAdapter($name, $adapter, $container, $factories); $adapters[$name] = $this->createAdapter($name, $adapter, $container, $this->factories);
} }
$map = array(); $map = array();
@ -59,6 +53,19 @@ class KnpGaufretteExtension extends Extension
} }
} }
public function getConfiguration(array $configs, ContainerBuilder $container)
{
$processor = new Processor();
// first assemble the adapter factories
$factoryConfig = new FactoryConfiguration();
$config = $processor->processConfiguration($factoryConfig, $configs);
$factories = $this->createAdapterFactories($config, $container);
// then normalize the configs
return new MainConfiguration($factories);
}
private function createAdapter($name, array $config, ContainerBuilder $container, array $factories) private function createAdapter($name, array $config, ContainerBuilder $container, array $factories)
{ {
$adapter = null; $adapter = null;