I want the next Symfony configuration for a bundle:
'foo' => [
'bar' => [
'item_1' => [
[
'id' => '25',
'url' => 'https://foo',
],
[
'id' => '26',
'url' => 'https://bar',
],
],
],
]
and I want to get keep all keys, so I used useAttributeAsKey:
class Configuration implements ConfigurationInterface
{
/**
* Generates the configuration tree builder.
*
* @return TreeBuilder $builder The tree builder
*/
public function getConfigTreeBuilder()
{
$builder = new TreeBuilder();
$rootNode = $builder->root('foo');
$rootNode->children()
->arrayNode('bar')
->useAttributeAsKey('name')
->arrayPrototype()
->children()
->scalarNode('id')->end()
->scalarNode('url')->end()
->end()
->end()
->end()
->end();
return $builder;
}
}
However, I'm getting this error:
"Unrecognized options "0, 1" under "foo.bar.item_1""
Reading https://symfony.com/doc/4.4/components/config/definition.html I understand this should work. Any idea?