Skip to content

Commit f72af10

Browse files
committed
feature #6593 Adding the payload parameter to the callback examples (jorgelbg)
This PR was merged into the 3.1 branch. Discussion ---------- Adding the payload parameter to the callback examples Updating the examples in http://symfony.com/doc/current/reference/constraints/Callback.html to show the existence of the `$payload` parameter, although at the moment none of the examples makes use of this parameter. | Q | A | ------------- | --- | Doc fix? | yes | New docs? | no | Applies to | 3.1,3.2 | Fixed tickets | #6185 Commits ------- b1e586b Adding the payload parameter to the callback examples
2 parents df73214 + b1e586b commit f72af10

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

reference/constraints/Callback.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ Configuration
4646
/**
4747
* @Assert\Callback
4848
*/
49-
public function validate(ExecutionContextInterface $context)
49+
public function validate(ExecutionContextInterface $context, $payload)
5050
{
5151
// ...
5252
}
@@ -103,7 +103,7 @@ field those errors should be attributed::
103103
// ...
104104
private $firstName;
105105

106-
public function validate(ExecutionContextInterface $context)
106+
public function validate(ExecutionContextInterface $context, $payload)
107107
{
108108
// somehow you have an array of "fake names"
109109
$fakeNames = array(/* ... */);
@@ -123,7 +123,7 @@ Static Callbacks
123123
You can also use the constraint with static methods. Since static methods don't
124124
have access to the object instance, they receive the object as the first argument::
125125

126-
public static function validate($object, ExecutionContextInterface $context)
126+
public static function validate($object, ExecutionContextInterface $context, $payload)
127127
{
128128
// somehow you have an array of "fake names"
129129
$fakeNames = array(/* ... */);
@@ -151,7 +151,7 @@ Suppose your validation function is ``Vendor\Package\Validator::validate()``::
151151

152152
class Validator
153153
{
154-
public static function validate($object, ExecutionContextInterface $context)
154+
public static function validate($object, ExecutionContextInterface $context, $payload)
155155
{
156156
// ...
157157
}
@@ -240,7 +240,7 @@ constructor of the Callback constraint::
240240
{
241241
public static function loadValidatorMetadata(ClassMetadata $metadata)
242242
{
243-
$callback = function ($object, ExecutionContextInterface $context) {
243+
$callback = function ($object, ExecutionContextInterface $context, $payload) {
244244
// ...
245245
};
246246

0 commit comments

Comments
 (0)