diff --git a/src/Admin/AbstractAdmin.php b/src/Admin/AbstractAdmin.php index 86800981944..abd214c3996 100644 --- a/src/Admin/AbstractAdmin.php +++ b/src/Admin/AbstractAdmin.php @@ -391,6 +391,8 @@ abstract class AbstractAdmin implements AdminInterface, DomainObjectInterface, A protected $securityHandler; /** + * NEXT_MAJOR: Remove this property. + * * @var ValidatorInterface */ protected $validator; @@ -2848,6 +2850,11 @@ public function id($model) return $this->getNormalizedIdentifier($model); } + /** + * NEXT_MAJOR: Remove this method. + * + * @deprecated since sonata-project/admin-bundle 3.x. + */ public function setValidator($validator) { // NEXT_MAJOR: Move ValidatorInterface check to method signature @@ -2861,8 +2868,18 @@ public function setValidator($validator) $this->validator = $validator; } + /** + * NEXT_MAJOR: Remove this method. + * + * @deprecated since sonata-project/admin-bundle 3.x. + */ public function getValidator() { + @trigger_error(sprintf( + 'The %s method is deprecated since version 3.x and will be removed in 4.0.', + __METHOD__ + ), E_USER_DEPRECATED); + return $this->validator; } diff --git a/src/Admin/AdminInterface.php b/src/Admin/AdminInterface.php index 6555e1398eb..34e6bc68290 100644 --- a/src/Admin/AdminInterface.php +++ b/src/Admin/AdminInterface.php @@ -328,14 +328,22 @@ public function getNormalizedIdentifier($model); public function id($model); /** + * NEXT_MAJOR: remove this method. + * * @param ValidatorInterface $validator * * @return void + * + * @deprecated since sonata-project/admin-bundle 3.x. */ public function setValidator($validator); /** + * NEXT_MAJOR: remove this method. + * * @return ValidatorInterface + * + * @deprecated since sonata-project/admin-bundle 3.x. */ public function getValidator(); diff --git a/src/DependencyInjection/Compiler/AddDependencyCallsCompilerPass.php b/src/DependencyInjection/Compiler/AddDependencyCallsCompilerPass.php index 854767da767..b6d3d87bc34 100644 --- a/src/DependencyInjection/Compiler/AddDependencyCallsCompilerPass.php +++ b/src/DependencyInjection/Compiler/AddDependencyCallsCompilerPass.php @@ -232,7 +232,7 @@ public function applyConfigurationFromAttribute(Definition $definition, array $a 'translator', 'configuration_pool', 'router', - 'validator', + 'validator', //NEXT_MAJOR: Remove this line 'security_handler', 'menu_factory', 'route_builder', @@ -280,7 +280,7 @@ public function applyDefaults(ContainerBuilder $container, $serviceId, array $at 'translator' => 'translator', 'configuration_pool' => 'sonata.admin.pool', 'route_generator' => 'sonata.admin.route.default_generator', - 'validator' => 'validator', + 'validator' => 'validator', //NEXT_MAJOR: Remove this line 'security_handler' => 'sonata.admin.security.handler', 'menu_factory' => 'knp_menu.factory', 'route_builder' => 'sonata.admin.route.path_info'. diff --git a/src/DependencyInjection/Configuration.php b/src/DependencyInjection/Configuration.php index 695fc96dcf5..881e00c642f 100644 --- a/src/DependencyInjection/Configuration.php +++ b/src/DependencyInjection/Configuration.php @@ -353,6 +353,7 @@ public function getConfigTreeBuilder() ->scalarNode('translator')->defaultNull()->end() ->scalarNode('configuration_pool')->defaultNull()->end() ->scalarNode('route_generator')->defaultNull()->end() + // NEXT_MAJOR: remove validator option ->scalarNode('validator')->defaultNull()->end() ->scalarNode('security_handler')->defaultNull()->end() ->scalarNode('label')->defaultNull()->end() diff --git a/tests/Admin/AdminTest.php b/tests/Admin/AdminTest.php index c34c5c59031..b9b1a75298c 100644 --- a/tests/Admin/AdminTest.php +++ b/tests/Admin/AdminTest.php @@ -954,6 +954,11 @@ public function testGetFormTheme(): void $this->assertSame(['FooTheme'], $admin->getFormTheme()); } + /* + * @group legacy + * + * NEXT_MAJOR: remove this test + */ public function testGetValidator(): void { $admin = new PostAdmin('sonata.post.admin.post', 'NewsBundle\Entity\Post', 'Sonata\NewsBundle\Controller\PostAdminController'); @@ -964,6 +969,7 @@ public function testGetValidator(): void $admin->setValidator($validator); $this->assertSame($validator, $admin->getValidator()); + $this->expectDeprecation('Since sonata-project/admin-bundle 3.x: This "%s" method is deprecated'); } public function testGetSecurityHandler(): void