From d7d91972d010ff063e2ba876cdd5390559ff0f39 Mon Sep 17 00:00:00 2001 From: Peter Gribanov Date: Wed, 14 Aug 2019 17:44:29 +0300 Subject: [PATCH 1/2] add fix for Symfony >4.2 in Configuration --- src/DependencyInjection/Configuration.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/DependencyInjection/Configuration.php b/src/DependencyInjection/Configuration.php index 9b5a554..2fbe7ac 100644 --- a/src/DependencyInjection/Configuration.php +++ b/src/DependencyInjection/Configuration.php @@ -19,8 +19,15 @@ class Configuration implements ConfigurationInterface */ public function getConfigTreeBuilder() { - $builder = new TreeBuilder(); - $builder->root('gpslab_pagination') + if (method_exists('Symfony\Component\Config\Definition\Builder\TreeBuilder', 'getRootNode')) { // Symfony >4.2 + $builder = new TreeBuilder('gpslab_pagination'); + $root = $builder->getRootNode(); + } else { + $builder = new TreeBuilder(); + $root = $builder->root('gpslab_pagination'); + } + + $root ->addDefaultsIfNotSet() ->children() ->scalarNode('max_navigate') From b34979630909f40d181633cfd17e7897fb057986 Mon Sep 17 00:00:00 2001 From: Peter Gribanov Date: Wed, 14 Aug 2019 17:53:50 +0300 Subject: [PATCH 2/2] change test code in Configuration class --- src/DependencyInjection/Configuration.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/DependencyInjection/Configuration.php b/src/DependencyInjection/Configuration.php index 2fbe7ac..d4a85b2 100644 --- a/src/DependencyInjection/Configuration.php +++ b/src/DependencyInjection/Configuration.php @@ -19,12 +19,14 @@ class Configuration implements ConfigurationInterface */ public function getConfigTreeBuilder() { - if (method_exists('Symfony\Component\Config\Definition\Builder\TreeBuilder', 'getRootNode')) { // Symfony >4.2 - $builder = new TreeBuilder('gpslab_pagination'); - $root = $builder->getRootNode(); + $tree_builder = new TreeBuilder('gpslab_pagination'); + + if (method_exists($tree_builder, 'getRootNode')) { + // Symfony 4.2 + + $root = $tree_builder->getRootNode(); } else { - $builder = new TreeBuilder(); - $root = $builder->root('gpslab_pagination'); + // Symfony 4.1 and below + $root = $tree_builder->root('gpslab_pagination'); } $root @@ -41,6 +43,6 @@ public function getConfigTreeBuilder() ->end() ->end(); - return $builder; + return $tree_builder; } }