ConstraintAValidator.php 921 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Component\Validator\Tests\Fixtures;
  11. use Symfony\Component\Validator\Constraint;
  12. use Symfony\Component\Validator\ConstraintValidator;
  13. use Symfony\Component\Validator\ExecutionContextInterface;
  14. class ConstraintAValidator extends ConstraintValidator
  15. {
  16. public static $passedContext;
  17. public function initialize(ExecutionContextInterface $context)
  18. {
  19. parent::initialize($context);
  20. self::$passedContext = $context;
  21. }
  22. public function validate($value, Constraint $constraint)
  23. {
  24. if ('VALID' != $value) {
  25. $this->context->addViolation('message', array('param' => 'value'));
  26. return;
  27. }
  28. }
  29. }