Elao/WebProfilerExtraBundle — Issue #9: Loading multiple configs with different environments, is it intentional?
Author: srosato
Created: 2011-10-30 02:38:02+00:00
State: open

Hi there, I am currently using Behat under test environment to run behaviour driven features and the WebProfilerExtraBundle conflicted when the switching from multiple requests. Since I didn't need the extra tools under the dev environment, I went away and added in config_test.yml:

```yaml
web_profiler_extra:
routing: false
container: false
assetic: false
twig: false
```
from config_dev.yml I have:

```yaml
web_profiler_extra:
routing: true
container: true
assetic: true
twig: true
```

The thing is, it does not **override**, each config is parsed as a whole here:

```php
class WebProfilerExtraExtension extends Extension
{
protected $resources = array(
'routing' => array('file' => 'routing.xml'),
'container' => array('file' => 'container.xml'),
'assetic' => array('file' => 'assetic.xml'),
'twig'	=> array('file' => 'twig.xml')
);

public function load(array $configs, ContainerBuilder $container)
{
foreach ($configs as $config) {
$this->doConfigLoad($config, $container);
}
}

protected function doConfigLoad(array $config, ContainerBuilder $container)
{
$loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));

foreach ($this->resources as $key => $resource)
{
if (isset($config[$key]))
{
$loader->load($resource['file']);
}
}
}
```

Is this intentional? I am able to disable the profiler simply by using one overridable configuration like this:

```php
class WebProfilerExtraExtension extends Extension
{
protected $resources = array(
'routing' => array('file' => 'routing.xml'),
'container' => array('file' => 'container.xml'),
'assetic' => array('file' => 'assetic.xml'),
'twig'	=> array('file' => 'twig.xml')
);

public function load(array $configs, ContainerBuilder $container)
{
$conf = array();
foreach ($configs as $config) {
$conf = array_merge($conf, $config);
}

$this->doConfigLoad($conf, $container);
}

protected function doConfigLoad(array $config, ContainerBuilder $container)
{
$loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));

foreach ($this->resources as $key => $resource)
{
if (isset($config[$key]) && $config[$key])
{
$loader->load($resource['file']);
}
}
}
```
I didn't think of other ways to disable it under the test env while still keeping it enabled for dev without doing the configuration overriding. What are your thoughts on that?

Best regards,
Steven Rosato