Skip to content

Commit

Permalink
Fix: Deprecation: A tree builder without a root node is deprecated si…
Browse files Browse the repository at this point in the history
…nce symfony 4.2 (#1457)

* Fix: Deprecation: A tree builder without a root node is deprecated since Symfony 4.2 and will not be supported anymore in 5.0.

* Fix: Deprecation: A tree builder without a root node is deprecated since Symfony 4.2 and will not be supported anymore in 5.0.
  • Loading branch information
mantis authored and phansys committed Mar 15, 2021
1 parent 2b39523 commit b54c493
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,16 @@ class Configuration implements ConfigurationInterface
{
public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder();
$treeBuilder
->root('nelmio_api_doc')
$treeBuilder = new TreeBuilder('nelmio_api_doc');

if (method_exists($treeBuilder, 'getRootNode')) {
$rootNode = $treeBuilder->getRootNode();
} else {
// symfony < 4.2 support
$rootNode = $treeBuilder->root('nelmio_api_doc');
}

$rootNode
->children()
->scalarNode('name')->defaultValue('API documentation')->end()
->arrayNode('exclude_sections')
Expand Down

0 comments on commit b54c493

Please sign in to comment.