a30a679135
A new ExecutionContext is now created everytime that GraphWalker::walkConstraint() is launched. Because of this, a validator B launched from within a validator A can't break A anymore by changing the context. Because we have a new ExecutionContext for every constraint validation, there is no point in modifying its state anymore. Because of this it is now immutable.
31 lines
688 B
PHP
31 lines
688 B
PHP
<?php
|
|
|
|
namespace Symfony\Tests\Component\Validator\Fixtures;
|
|
|
|
use Symfony\Component\Validator\Constraint;
|
|
use Symfony\Component\Validator\ConstraintValidator;
|
|
use Symfony\Component\Validator\ExecutionContext;
|
|
|
|
class ConstraintAValidator extends ConstraintValidator
|
|
{
|
|
static public $passedContext;
|
|
|
|
public function initialize(ExecutionContext $context)
|
|
{
|
|
parent::initialize($context);
|
|
|
|
self::$passedContext = $context;
|
|
}
|
|
|
|
public function isValid($value, Constraint $constraint)
|
|
{
|
|
if ('VALID' != $value) {
|
|
$this->setMessage('message', array('param' => 'value'));
|
|
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
}
|