Under Defining and Processing Configuration Values in the documentation for the Symfony Config component, it's implied that the root node name you pass to the TreeBuilder
constructor will be seen as a node at the root of the configurations the processor is passed, rather than the root of the objects themselves.
It certainly seems like things are handled this way when loading files into a container, but the following code follows what I understand the documentation to be describing, yet throws an InvalidConfigurationException
claiming Unrecognized option "foo" under "foo". Available option is "bar". on all currently supported versions of Symfony.
I'm baffled; can anyone, please, help me understand what's going on here?
class Config implements \Symfony\Component\Config\Definition\ConfigurationInterface
{
public function getConfigTreeBuilder()
{
$builder = new \Symfony\Component\Config\Definition\Builder\TreeBuilder('foo');
$builder->getRootNode()
->children()
->scalarNode('bar')->end()
->end();
return $builder;
}
}
$config = new Config();
$processor = new \Symfony\Component\Config\Definition\Processor();
$a = ['foo' => ['bar' => 'a']];
$b = ['foo' => ['bar' => 'b']];
$c = $processor->processConfiguration($config, [$a, $b]);