From 5e618d3ad02af3675f42dd16df42bfd00428d33e Mon Sep 17 00:00:00 2001 From: Vincent Langlet Date: Tue, 27 Apr 2021 22:36:40 +0200 Subject: [PATCH] Stop using SonataAdmin config in doctrineORMAdmin --- .../Compiler/AddAuditEntityCompilerPass.php | 4 +++ .../Compiler/AddGuesserCompilerPass.php | 4 +++ .../Compiler/AddTemplatesCompilerPass.php | 35 ++++++++++--------- src/DependencyInjection/Configuration.php | 4 +++ 4 files changed, 30 insertions(+), 17 deletions(-) diff --git a/src/DependencyInjection/Compiler/AddAuditEntityCompilerPass.php b/src/DependencyInjection/Compiler/AddAuditEntityCompilerPass.php index 95ab25281..bec1859c6 100755 --- a/src/DependencyInjection/Compiler/AddAuditEntityCompilerPass.php +++ b/src/DependencyInjection/Compiler/AddAuditEntityCompilerPass.php @@ -17,6 +17,10 @@ use Symfony\Component\DependencyInjection\ContainerBuilder; /** + * NEXT_MAJOR: Remove the "since" part of the internal annotation. + * + * @internal since sonata-project/admin-bundle version 4.0 + * * @final since sonata-project/doctrine-orm-admin-bundle 3.24 * * @author Thomas Rabaix diff --git a/src/DependencyInjection/Compiler/AddGuesserCompilerPass.php b/src/DependencyInjection/Compiler/AddGuesserCompilerPass.php index 73e326b44..19a3a7e71 100644 --- a/src/DependencyInjection/Compiler/AddGuesserCompilerPass.php +++ b/src/DependencyInjection/Compiler/AddGuesserCompilerPass.php @@ -18,6 +18,10 @@ use Symfony\Component\DependencyInjection\Reference; /** + * NEXT_MAJOR: Remove the "since" part of the internal annotation. + * + * @internal since sonata-project/admin-bundle version 4.0 + * * @final since sonata-project/doctrine-orm-admin-bundle 3.24 * * @author Thomas Rabaix diff --git a/src/DependencyInjection/Compiler/AddTemplatesCompilerPass.php b/src/DependencyInjection/Compiler/AddTemplatesCompilerPass.php index 626b7fc81..ff278dd3f 100644 --- a/src/DependencyInjection/Compiler/AddTemplatesCompilerPass.php +++ b/src/DependencyInjection/Compiler/AddTemplatesCompilerPass.php @@ -18,6 +18,10 @@ use Symfony\Component\DependencyInjection\Definition; /** + * NEXT_MAJOR: Remove the "since" part of the internal annotation. + * + * @internal since sonata-project/admin-bundle version 4.0 + * * @final since sonata-project/doctrine-orm-admin-bundle 3.24 * * @author Thomas Rabaix @@ -26,7 +30,6 @@ class AddTemplatesCompilerPass implements CompilerPassInterface { public function process(ContainerBuilder $container) { - $overwrite = $container->getParameter('sonata.admin.configuration.admin_services'); $templates = $container->getParameter('sonata_doctrine_orm_admin.templates'); foreach ($container->findTaggedServiceIds('sonata.admin') as $id => $attributes) { @@ -36,32 +39,30 @@ public function process(ContainerBuilder $container) $definition = $container->getDefinition($id); - if (!$definition->hasMethodCall('setFormTheme')) { - $definition->addMethodCall('setFormTheme', [$templates['form']]); - } - - if (isset($overwrite[$id]['templates']['form'])) { - $this->mergeMethodCall($definition, 'setFormTheme', $overwrite[$id]['templates']['form']); - } + // NEXT_MAJOR: Remove this line and uncomment the following + $this->mergeMethodCall($definition, 'setFormTheme', $templates['form']); +// $this->mergeMethodCall($definition, 'setFormTheme', ['@SonataDoctrineORMAdmin/Form/form_admin_fields.html.twig']); - if (!$definition->hasMethodCall('setFilterTheme')) { - $definition->addMethodCall('setFilterTheme', [$templates['filter']]); - } - - if (isset($overwrite[$id]['templates']['filter'])) { - $this->mergeMethodCall($definition, 'setFilterTheme', $overwrite[$id]['templates']['filter']); - } + // NEXT_MAJOR: Remove this line and uncomment the following + $this->mergeMethodCall($definition, 'setFilterTheme', $templates['filter']); +// $this->mergeMethodCall($definition, 'setFilterTheme', ['@SonataDoctrineORMAdmin/Form/filter_admin_fields.html.twig']); } } /** - * @param string $name - * @param mixed $value + * @param string $name + * @param array $value * * @return void */ public function mergeMethodCall(Definition $definition, $name, $value) { + if (!$definition->hasMethodCall($name)) { + $definition->addMethodCall($name, [$value]); + + return; + } + $methodCalls = $definition->getMethodCalls(); foreach ($methodCalls as &$calls) { diff --git a/src/DependencyInjection/Configuration.php b/src/DependencyInjection/Configuration.php index a2efb6232..ab2c1b9c2 100644 --- a/src/DependencyInjection/Configuration.php +++ b/src/DependencyInjection/Configuration.php @@ -56,11 +56,15 @@ public function getConfigTreeBuilder() ->arrayNode('templates') ->addDefaultsIfNotSet() ->children() + // NEXT_MAJOR: Remove this option. ->arrayNode('form') + ->setDeprecated('The "%node%" option is deprecated since sonata-project/admin-bundle 3.x.') ->prototype('scalar')->end() ->defaultValue(['@SonataDoctrineORMAdmin/Form/form_admin_fields.html.twig']) ->end() + // NEXT_MAJOR: Remove this option. ->arrayNode('filter') + ->setDeprecated('The "%node%" option is deprecated since sonata-project/admin-bundle 3.x.') ->prototype('scalar')->end() ->defaultValue(['@SonataDoctrineORMAdmin/Form/filter_admin_fields.html.twig']) ->end()