From 34fa80b8a8cb9bd7c96696828f2b78bd8839c391 Mon Sep 17 00:00:00 2001 From: Fran Moreno Date: Sun, 16 Dec 2018 17:05:02 +0100 Subject: [PATCH] Fix deprecation for symfony/config 4.2+ --- src/CoreBundle/DependencyInjection/Configuration.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/CoreBundle/DependencyInjection/Configuration.php b/src/CoreBundle/DependencyInjection/Configuration.php index 99aa761e..5f51c8a8 100644 --- a/src/CoreBundle/DependencyInjection/Configuration.php +++ b/src/CoreBundle/DependencyInjection/Configuration.php @@ -25,8 +25,14 @@ class Configuration implements ConfigurationInterface { public function getConfigTreeBuilder() { - $treeBuilder = new TreeBuilder(); - $rootNode = $treeBuilder->root('sonata_core'); + $treeBuilder = new TreeBuilder('sonata_core'); + + // Keep compatibility with symfony/config < 4.2 + if (!\method_exists($treeBuilder, 'getRootNode')) { + $rootNode = $treeBuilder->root('sonata_core'); + } else { + $rootNode = $treeBuilder->getRootNode(); + } $this->addFlashMessageSection($rootNode); $this->addSerializerFormats($rootNode);