This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
symfony/tests/Symfony/Tests/Component/Validator/Fixtures/ConstraintAValidator.php
Bernhard Schussek a30a679135 [Validator] Made ExecutionContext immutable and introduced new class GlobalExecutionContext
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.
2012-01-31 21:35:48 +01:00

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;
}
}