[Validator] do not treat payload as callback

This commit is contained in:
Christian Flothmann 2016-03-24 15:49:51 +01:00
parent bd6d9bb1c2
commit 2066fc03c7
3 changed files with 4 additions and 4 deletions

View File

@ -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);
}
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) {
$options = array('callback' => $options);
} else {

View File

@ -85,7 +85,7 @@ class Entity extends EntityParent implements EntityInterface
}
/**
* @Assert\Callback
* @Assert\Callback(payload="foo")
*/
public function validateMe(ExecutionContextInterface $context)
{

View File

@ -53,7 +53,7 @@ class AnnotationLoaderTest extends \PHPUnit_Framework_TestCase
$expected->setGroupSequence(array('Foo', 'Entity'));
$expected->addConstraint(new ConstraintA());
$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->addPropertyConstraint('firstName', new NotNull());
$expected->addPropertyConstraint('firstName', new Range(array('min' => 3)));
@ -123,7 +123,7 @@ class AnnotationLoaderTest extends \PHPUnit_Framework_TestCase
$expected->setGroupSequence(array('Foo', 'Entity'));
$expected->addConstraint(new ConstraintA());
$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->addPropertyConstraint('firstName', new NotNull());
$expected->addPropertyConstraint('firstName', new Range(array('min' => 3)));