[Validator] do not treat payload as callback
This commit is contained in:
parent
bd6d9bb1c2
commit
2066fc03c7
@ -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