From 1df45e9d7189bc8c3c74ef6e3ae3d0e265515e9a Mon Sep 17 00:00:00 2001 From: Alexey Date: Tue, 22 Feb 2022 17:28:04 +0300 Subject: [PATCH] fix deprecations for symfony >= 4.2 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, 7 insertions(+), 6 deletions(-) diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index 9fd268e..d662e8d 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -17,12 +17,13 @@ class Configuration implements ConfigurationInterface */ public function getConfigTreeBuilder() { - $treeBuilder = new TreeBuilder(); - $rootNode = $treeBuilder->root('intaro_twig_sandbox'); - - // Here you should define the parameters that are allowed to - // configure your bundle. See the documentation linked above for - // more information on that topic. + $treeBuilder = new TreeBuilder('intaro_twig_sandbox'); + if (\method_exists($treeBuilder, 'getRootNode')) { + $rootNode = $treeBuilder->getRootNode(); + } else { + // BC layer for symfony/config 4.1 and older + $rootNode = $treeBuilder->root('intaro_twig_sandbox'); + } return $treeBuilder; }