Skip to content

Commit dc059ab

Browse files
committed
[Validator] Added default validate() implementation to ConstraintValidator for BC
1 parent 6336d93 commit dc059ab

File tree

1 file changed

+26
-5
lines changed

1 file changed

+26
-5
lines changed

src/Symfony/Component/Validator/ConstraintValidator.php

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@
1111

1212
namespace Symfony\Component\Validator;
1313

14+
use Symfony\Component\Validator\Exception\ValidatorException;
15+
1416
/**
1517
* Base class for constraint validators
1618
*
1719
* @author Bernhard Schussek <bschussek@gmail.com>
1820
*
1921
* @api
2022
*/
21-
use Symfony\Component\Validator\Exception\ValidatorException;
22-
2323
abstract class ConstraintValidator implements ConstraintValidatorInterface
2424
{
2525
/**
@@ -54,7 +54,7 @@ public function initialize(ExecutionContext $context)
5454
/**
5555
* {@inheritDoc}
5656
*
57-
* @deprecated
57+
* @deprecated Deprecated since version 2.1, to be removed in 2.3.
5858
*/
5959
public function getMessageTemplate()
6060
{
@@ -64,7 +64,7 @@ public function getMessageTemplate()
6464
/**
6565
* {@inheritDoc}
6666
*
67-
* @deprecated
67+
* @deprecated Deprecated since version 2.1, to be removed in 2.3.
6868
*/
6969
public function getMessageParameters()
7070
{
@@ -74,7 +74,7 @@ public function getMessageParameters()
7474
/**
7575
* Wrapper for $this->context->addViolation()
7676
*
77-
* @deprecated
77+
* @deprecated Deprecated since version 2.1, to be removed in 2.3.
7878
*/
7979
protected function setMessage($template, array $parameters = array())
8080
{
@@ -87,4 +87,25 @@ protected function setMessage($template, array $parameters = array())
8787

8888
$this->context->addViolation($template, $parameters);
8989
}
90+
91+
/**
92+
* Stub implementation delegating to the deprecated isValid method.
93+
*
94+
* This stub exists for BC and will be dropped in Symfony 2.3.
95+
*
96+
* @see ConstraintValidatorInterface::validate
97+
*/
98+
public function validate($value, Constraint $constraint)
99+
{
100+
return $this->isValid($valoue, $constraint);
101+
}
102+
103+
/**
104+
* BC variant of validate.
105+
*
106+
* @deprecated Deprecated since version 2.1, to be removed in 2.3.
107+
*/
108+
protected function isValid($value, Constraint $constraint)
109+
{
110+
}
90111
}

0 commit comments

Comments
 (0)