Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Config] Support for dynamic array node definitions #17436

Open
sandrokeil opened this issue Jan 19, 2016 · 2 comments
Open

[Config] Support for dynamic array node definitions #17436

sandrokeil opened this issue Jan 19, 2016 · 2 comments
Labels

Comments

@sandrokeil
Copy link

@sandrokeil sandrokeil commented Jan 19, 2016

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;
    }
}
@xabbuh xabbuh added the Config label Jan 19, 2016
@xabbuh

This comment has been minimized.

Copy link
Member

@xabbuh xabbuh commented 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

This comment has been minimized.

Copy link
Author

@sandrokeil sandrokeil commented 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 to array instead of dynamicArray.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.