From b54c4933ef78099e32b22418bfb4ac4d14f3c010 Mon Sep 17 00:00:00 2001 From: mantis Date: Fri, 25 Jan 2019 17:17:45 +0000 Subject: [PATCH] Fix: Deprecation: A tree builder without a root node is deprecated since 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. --- DependencyInjection/Configuration.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index c71e33000..a2cecf6a1 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -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')