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

Symfony Config: two new methods for configuration definition tree manipulation to better reuse #27534

cejen opened this Issue Jun 7, 2018 · 0 comments


None yet
2 participants

cejen commented Jun 7, 2018

I can't find any way to make some parts of configuration definition reuseable. The best approach by me is to add two methods which can provides configuration tree manipulation (similar to DOM manipulation). But any other approach is welcome.

  1. \\Symfony\\Component\\Config\\Definition\\TreeBuilder::findNode(string $path):NodeDefinition - this method find node on given path (e.g. $node = $treeBuilder->findNode('node_name\node_name\node_name')
  2. \\Symfony\\Component\\Config\\Definition\\Builder\\NodeDefinition::addNode(NodeDefinition $node): NodeDefinition - this method adds given node under.


class EventDispatcherConfig implements ConfigurationInterface {

    private function addSerializerDefinition(NodeDefinition $node, $comment)
            (new ArrayNodeDefinition('serializer', $node))
                        ->values(['json', 'xml'])

    public function getConfigTreeBuilder()
        $treeBuilder = new TreeBuilder();
        $rootNode = $treeBuilder->root('A');
        // Now i can add repetitive definitions into
            'Default serializer used to serialize enqueued events (used when route definition does not contain serializer definition'));
            'Serializer used to serialize enqueued events'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment