From ce6b7c90491f04cfe6c822dae147501124d3c03a Mon Sep 17 00:00:00 2001 From: johnkrovitch Date: Thu, 25 Jun 2020 00:34:56 +0200 Subject: [PATCH] Re-add compatibility with Symfony 3.4 as it is required for the recipe --- .scrutinizer.yml | 2 +- .travis.yml | 1 + src/Configuration/ActionConfiguration.php | 16 ------------ src/DependencyInjection/Configuration.php | 32 ++++++++++++++++++----- 4 files changed, 27 insertions(+), 24 deletions(-) diff --git a/.scrutinizer.yml b/.scrutinizer.yml index 99bd6605c..37ffbfe2e 100644 --- a/.scrutinizer.yml +++ b/.scrutinizer.yml @@ -1,7 +1,7 @@ tools: external_code_coverage: timeout: 2000 - runs: 2 + runs: 12 filter: excluded_paths: diff --git a/.travis.yml b/.travis.yml index b5fe1d9c1..eca9ff414 100644 --- a/.travis.yml +++ b/.travis.yml @@ -30,6 +30,7 @@ after_script: - php ocular.phar code-coverage:upload --format=php-clover var/phpunit/logs/clover.xml env: + - SYMFONY_VERSION=3.4.* - SYMFONY_VERSION=4.4.* - SYMFONY_VERSION=5.0.* - SYMFONY_VERSION=5.1.* diff --git a/src/Configuration/ActionConfiguration.php b/src/Configuration/ActionConfiguration.php index 88803d41a..384596bde 100644 --- a/src/Configuration/ActionConfiguration.php +++ b/src/Configuration/ActionConfiguration.php @@ -363,22 +363,6 @@ protected function configureMenu(OptionsResolver $resolver): void $value = []; } -// foreach ($value as $menuName => $menuConfiguration) { -// if (count($value) !== 0) { -// return $value; -// } -// -// if ($menuName === 'top') { -// if ($this->actionName === 'create') { -// if (empty($menuConfiguration['children']) || count($menuConfiguration['children']) === 0) { -// $value[$menuName]['children'] = [ -// 'create' => null, -// ]; -// } -// } -// } -// } - return $value; }) ; diff --git a/src/DependencyInjection/Configuration.php b/src/DependencyInjection/Configuration.php index f168c5484..72e447a80 100644 --- a/src/DependencyInjection/Configuration.php +++ b/src/DependencyInjection/Configuration.php @@ -16,7 +16,12 @@ class Configuration implements ConfigurationInterface public function getConfigTreeBuilder() { $treeBuilder = new TreeBuilder('lag_admin'); - $rootNode = $treeBuilder->getRootNode(); + + if (method_exists(TreeBuilder::class, 'getRootNode')) { + $rootNode = $treeBuilder->getRootNode(); + } else { + $rootNode = $treeBuilder->root('lag_admin'); + } $rootNode ->children() @@ -32,13 +37,28 @@ public function getConfigTreeBuilder() return $treeBuilder; } + /** + * This method preserves the compatibility with Symfony 3.4. + */ + protected function createRootNode(string $name): NodeDefinition + { + if (method_exists(TreeBuilder::class, 'getRootNode')) { + $treeBuilder = new TreeBuilder($name); + + return $treeBuilder->getRootNode(); + } else { + $treeBuilder = new TreeBuilder(); + + return $treeBuilder->root($name); + } + } + /** * @return ArrayNodeDefinition|NodeDefinition */ protected function getAdminsConfigurationNode() { - $builder = new TreeBuilder('admins'); - $node = $builder->getRootNode(); + $node = $this->createRootNode('admins'); $node // useAttributeAsKey() method will preserve keys when multiple configurations files are used and then avoid @@ -64,8 +84,7 @@ protected function getAdminsConfigurationNode() */ protected function getApplicationNode() { - $builder = new TreeBuilder('application'); - $node = $builder->getRootNode(); + $node = $this->createRootNode('application'); $node ->children() @@ -123,8 +142,7 @@ protected function getApplicationNode() */ protected function getMenuConfiguration() { - $builder = new TreeBuilder('menus'); - $node = $builder->getRootNode(); + $node = $this->createRootNode('menus'); $node ->prototype('variable')