Skip to content

[Config] Support for dynamic array node definitions #17436

@sandrokeil

Description

@sandrokeil

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;
    }
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions