Skip to content

Commit

Permalink
Add deprecation notices
Browse files Browse the repository at this point in the history
  • Loading branch information
tambait committed Nov 27, 2020
1 parent ddbc55b commit 95a5692
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 1 deletion.
22 changes: 22 additions & 0 deletions src/Admin/AbstractAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,8 @@ abstract class AbstractAdmin implements AdminInterface, DomainObjectInterface, A
protected $securityHandler;

/**
* NEXT_MAJOR: Remove this property.
*
* @var ValidatorInterface
*/
protected $validator;
Expand Down Expand Up @@ -2848,8 +2850,18 @@ 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)
{
@trigger_error(sprintf(
'The %s method is deprecated since version 3.x and will be removed in 4.0.',
__METHOD__
), E_USER_DEPRECATED);

// NEXT_MAJOR: Move ValidatorInterface check to method signature
if (!$validator instanceof ValidatorInterface) {
throw new \InvalidArgumentException(sprintf(
Expand All @@ -2861,8 +2873,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;
}

Expand Down
8 changes: 8 additions & 0 deletions src/Admin/AdminInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,8 @@ static function (array $a, array $b): int {
/**
* NEXT_MAJOR: Change visibility to private.
*
* NEXT_MAJOR: Remove validator attribute key.
*
* This method read the attribute keys and configure admin class to use the related dependency.
*/
public function applyConfigurationFromAttribute(Definition $definition, array $attributes)
Expand Down Expand Up @@ -280,7 +282,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'.
Expand Down
1 change: 1 addition & 0 deletions src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 95a5692

Please sign in to comment.