6602fdcdc8bcdc3c7dc43ca08c24c2c2e55c3e0a
[yaffs-website] / web / core / modules / system / tests / modules / entity_test / src / Plugin / Validation / Constraint / EntityTestEntityLevelValidator.php
1 <?php
2
3 namespace Drupal\entity_test\Plugin\Validation\Constraint;
4
5 use Symfony\Component\Validator\Constraint;
6 use Symfony\Component\Validator\ConstraintValidator;
7
8 /**
9  * Constraint validator for the EntityTestEntityLevel constraint.
10  */
11 class EntityTestEntityLevelValidator extends ConstraintValidator {
12
13   /**
14    * Validator 2.5 and upwards compatible execution context.
15    *
16    * @var \Symfony\Component\Validator\Context\ExecutionContextInterface
17    */
18   protected $context;
19
20   /**
21    * {@inheritdoc}
22    */
23   public function validate($value, Constraint $constraint) {
24     if ($value->name->value === 'entity-level-violation') {
25       $this->context->buildViolation($constraint->message)
26         ->addViolation();
27     }
28   }
29
30 }