Closed
Description
To increase the interoperability it would be useful to have an option for dynamic array definitions in the configuration node builder. Framework agnostic libraries validates the configuration in the factory classes, so there is no need to redefine it for Symfony.
It exists a Symfony Interop Bundle which has support for dynamic array nodes. But this is not needed if we add an option to disable the exception and create a new ArrayNode
instead like in the Symfony Interop Bundle.
Here is an example (useDynmicArray()
):
class Configuration implements ConfigurationInterface
{
public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder();
$rootNode = $treeBuilder->root('prooph');
// our factories handles validation and we are flexible with keys
$rootNode->ignoreExtraKeys(false);
$rootNode->useDynamicArray(); // <-- new functionality
return $treeBuilder;
}
}
Activity
xabbuh commentedon Jan 19, 2016
Can you explain what configuration I would be able to do with that new option I wasn't able to create before? I am not sure I understand what you would like to solve.
sandrokeil commentedon Jan 19, 2016
If I provide a default configuration, in this case a PHP array, in the bundle and I want to override or extend the bundle configuration in the application
config.yml
I get the exception message merge() expects a normalized config array..Instead of throwing an exception, I need to create a new instance of ArrayNode, so the config could be merged. Or do I miss something? Note, that I don't want to define the whole config structure with the tree builder.
For a test case, you can use a Symonfy demo app and add the prooph Symfony bundle and then put the example YAML configuration to your
config.yml
file and with the debug:config console command you should get the exception message if you change this line toarray
instead ofdynamicArray
.carsonbot commentedon Dec 20, 2020
Thank you for this suggestion.
There has not been a lot of activity here for a while. Would you still like to see this feature?