bug #18298 [Validator] do not treat payload as callback (xabbuh)
This PR was merged into the 2.7 branch.
Discussion
----------
[Validator] do not treat payload as callback
| Q | A
| ------------- | ---
| Branch? | 2.7
| Bug fix? | yes
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets |
| License | MIT
| Doc PR |
see http://stackoverflow.com/a/36140305/2289865
Commits
-------
2066fc0
[Validator] do not treat payload as callback
This commit is contained in:
commit
3c1738a46b
@ -49,7 +49,7 @@ class Callback extends Constraint
|
|||||||
@trigger_error('The "methods" option of the '.__CLASS__.' class is deprecated since version 2.4 and will be removed in 3.0. Use the "callback" option instead.', E_USER_DEPRECATED);
|
@trigger_error('The "methods" option of the '.__CLASS__.' class is deprecated since version 2.4 and will be removed in 3.0. Use the "callback" option instead.', E_USER_DEPRECATED);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_array($options) && !isset($options['callback']) && !isset($options['methods']) && !isset($options['groups'])) {
|
if (is_array($options) && !isset($options['callback']) && !isset($options['methods']) && !isset($options['groups']) && !isset($options['payload'])) {
|
||||||
if (is_callable($options) || !$options) {
|
if (is_callable($options) || !$options) {
|
||||||
$options = array('callback' => $options);
|
$options = array('callback' => $options);
|
||||||
} else {
|
} else {
|
||||||
|
@ -85,7 +85,7 @@ class Entity extends EntityParent implements EntityInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Assert\Callback
|
* @Assert\Callback(payload="foo")
|
||||||
*/
|
*/
|
||||||
public function validateMe(ExecutionContextInterface $context)
|
public function validateMe(ExecutionContextInterface $context)
|
||||||
{
|
{
|
||||||
|
@ -53,7 +53,7 @@ class AnnotationLoaderTest extends \PHPUnit_Framework_TestCase
|
|||||||
$expected->setGroupSequence(array('Foo', 'Entity'));
|
$expected->setGroupSequence(array('Foo', 'Entity'));
|
||||||
$expected->addConstraint(new ConstraintA());
|
$expected->addConstraint(new ConstraintA());
|
||||||
$expected->addConstraint(new Callback(array('Symfony\Component\Validator\Tests\Fixtures\CallbackClass', 'callback')));
|
$expected->addConstraint(new Callback(array('Symfony\Component\Validator\Tests\Fixtures\CallbackClass', 'callback')));
|
||||||
$expected->addConstraint(new Callback('validateMe'));
|
$expected->addConstraint(new Callback(array('callback' => 'validateMe', 'payload' => 'foo')));
|
||||||
$expected->addConstraint(new Callback('validateMeStatic'));
|
$expected->addConstraint(new Callback('validateMeStatic'));
|
||||||
$expected->addPropertyConstraint('firstName', new NotNull());
|
$expected->addPropertyConstraint('firstName', new NotNull());
|
||||||
$expected->addPropertyConstraint('firstName', new Range(array('min' => 3)));
|
$expected->addPropertyConstraint('firstName', new Range(array('min' => 3)));
|
||||||
@ -123,7 +123,7 @@ class AnnotationLoaderTest extends \PHPUnit_Framework_TestCase
|
|||||||
$expected->setGroupSequence(array('Foo', 'Entity'));
|
$expected->setGroupSequence(array('Foo', 'Entity'));
|
||||||
$expected->addConstraint(new ConstraintA());
|
$expected->addConstraint(new ConstraintA());
|
||||||
$expected->addConstraint(new Callback(array('Symfony\Component\Validator\Tests\Fixtures\CallbackClass', 'callback')));
|
$expected->addConstraint(new Callback(array('Symfony\Component\Validator\Tests\Fixtures\CallbackClass', 'callback')));
|
||||||
$expected->addConstraint(new Callback('validateMe'));
|
$expected->addConstraint(new Callback(array('callback' => 'validateMe', 'payload' => 'foo')));
|
||||||
$expected->addConstraint(new Callback('validateMeStatic'));
|
$expected->addConstraint(new Callback('validateMeStatic'));
|
||||||
$expected->addPropertyConstraint('firstName', new NotNull());
|
$expected->addPropertyConstraint('firstName', new NotNull());
|
||||||
$expected->addPropertyConstraint('firstName', new Range(array('min' => 3)));
|
$expected->addPropertyConstraint('firstName', new Range(array('min' => 3)));
|
||||||
|
Reference in New Issue
Block a user