Symfony 5 TreeBuilder compatibility

Viewed 385

I have a symfony bundle working on Symfony 3 and 4. But Since Symfony 5, the method define configuration inside TreeBuilder has changed: Deprecated tree builders without root nodes.

From this

$treeBuilder = new TreeBuilder();
$rootNode = $treeBuilder->get('bundle_name');

To this

$treeBuilder = new TreeBuilder('bundle_name');
$rootNode = $treeBuilder->getRootNode();

Since I want my bundle to work from Symfony 3 and Symfony 5, how can I change the TreeBuilder to work in all the cases?

0 Answers
Related