Skip to content

Adding the payload parameter to the callback examples #6593

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 21, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions reference/constraints/Callback.rst
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ Configuration
/**
* @Assert\Callback
*/
public function validate(ExecutionContextInterface $context)
public function validate(ExecutionContextInterface $context, $payload)
{
// ...
}
Expand Down Expand Up @@ -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(/* ... */);
Expand All @@ -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(/* ... */);
Expand Down Expand Up @@ -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)
{
// ...
}
Expand Down Expand Up @@ -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) {
// ...
};

Expand Down