From 1751b89dd10de15826a5d1641a631469f6df23be Mon Sep 17 00:00:00 2001 From: Mondane Date: Wed, 15 May 2019 12:41:17 +0200 Subject: [PATCH] Create TreeBuilder with root defined. (#44) * Create TreeBuilder with root defined. Fix for 'A tree builder without a root node is deprecated since Symfony 4.2 and will not be supported anymore in 5.0.' * Add support for symfony < 4.2 The BC layer is taken from https://github.com/KnpLabs/KnpPaginatorBundle/commit/740b876d61b46de767e457b8b0f0850f3f323dea#diff-850942b3ba24ab03a40aaa81b6152852 --- DependencyInjection/Configuration.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index cbf4687..fe5fdb0 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -20,8 +20,9 @@ class Configuration implements ConfigurationInterface */ public function getConfigTreeBuilder() { - $treeBuilder = new TreeBuilder(); - $rootNode = $treeBuilder->root('apy_breadcrumb_trail'); + $treeBuilder = new TreeBuilder('apy_breadcrumb_trail'); + // BC layer for symfony/config < 4.2 + $rootNode = method_exists($treeBuilder, 'getRootNode') ? $treeBuilder->getRootNode() : $treeBuilder->root('apy_breadcrumb_trail'); $rootNode ->children()