Skip to content

Commit

Permalink
Re-add compatibility with Symfony 3.4 as it is required for the recipe
Browse files Browse the repository at this point in the history
  • Loading branch information
johnkrovitch committed Jun 25, 2020
1 parent a771025 commit ce6b7c9
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 24 deletions.
2 changes: 1 addition & 1 deletion .scrutinizer.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
tools:
external_code_coverage:
timeout: 2000
runs: 2
runs: 12

filter:
excluded_paths:
Expand Down
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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.*
Expand Down
16 changes: 0 additions & 16 deletions src/Configuration/ActionConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
})
;
Expand Down
32 changes: 25 additions & 7 deletions src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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
Expand All @@ -64,8 +84,7 @@ protected function getAdminsConfigurationNode()
*/
protected function getApplicationNode()
{
$builder = new TreeBuilder('application');
$node = $builder->getRootNode();
$node = $this->createRootNode('application');

$node
->children()
Expand Down Expand Up @@ -123,8 +142,7 @@ protected function getApplicationNode()
*/
protected function getMenuConfiguration()
{
$builder = new TreeBuilder('menus');
$node = $builder->getRootNode();
$node = $this->createRootNode('menus');

$node
->prototype('variable')
Expand Down

0 comments on commit ce6b7c9

Please sign in to comment.