From b1e586b8e116e2c10b0b105c539d313bcd962e23 Mon Sep 17 00:00:00 2001 From: Jorge Luis Betancourt Date: Sat, 21 May 2016 09:00:25 -0400 Subject: [PATCH] Adding the payload parameter to the callback examples --- reference/constraints/Callback.rst | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/reference/constraints/Callback.rst b/reference/constraints/Callback.rst index c5588bbf2fe..6329a1f5cf4 100644 --- a/reference/constraints/Callback.rst +++ b/reference/constraints/Callback.rst @@ -46,7 +46,7 @@ Configuration /** * @Assert\Callback */ - public function validate(ExecutionContextInterface $context) + public function validate(ExecutionContextInterface $context, $payload) { // ... } @@ -103,7 +103,7 @@ field those errors should be attributed:: // ... private $firstName; - public function validate(ExecutionContextInterface $context) + public function validate(ExecutionContextInterface $context, $payload) { // somehow you have an array of "fake names" $fakeNames = array(/* ... */); @@ -123,7 +123,7 @@ Static Callbacks You can also use the constraint with static methods. Since static methods don't have access to the object instance, they receive the object as the first argument:: - public static function validate($object, ExecutionContextInterface $context) + public static function validate($object, ExecutionContextInterface $context, $payload) { // somehow you have an array of "fake names" $fakeNames = array(/* ... */); @@ -151,7 +151,7 @@ Suppose your validation function is ``Vendor\Package\Validator::validate()``:: class Validator { - public static function validate($object, ExecutionContextInterface $context) + public static function validate($object, ExecutionContextInterface $context, $payload) { // ... } @@ -240,7 +240,7 @@ constructor of the Callback constraint:: { public static function loadValidatorMetadata(ClassMetadata $metadata) { - $callback = function ($object, ExecutionContextInterface $context) { + $callback = function ($object, ExecutionContextInterface $context, $payload) { // ... };