markConstraintAsValidated example

$constraintHash = $this->generateCacheKey($constraint, true);
                // instanceof Valid: In case of using a Valid constraint with many groups                 // it makes a reference object get validated by each group                 if ($constraint instanceof Composite || $constraint instanceof Valid) {
                    $constraintHash .= $group;
                }

                if ($context->isConstraintValidated($cacheKey$constraintHash)) {
                    continue;
                }

                $context->markConstraintAsValidated($cacheKey$constraintHash);
            }

            $context->setConstraint($constraint);

            $validator = $this->validatorFactory->getInstance($constraint);
            $validator->initialize($context);

            if ($value instanceof LazyProperty) {
                $value = $value->getPropertyValue();
            }

            
$constraintHash = $this->generateCacheKey($constraint, true);
                // instanceof Valid: In case of using a Valid constraint with many groups                 // it makes a reference object get validated by each group                 if ($constraint instanceof Composite || $constraint instanceof Valid) {
                    $constraintHash .= $group;
                }

                if ($context->isConstraintValidated($cacheKey$constraintHash)) {
                    continue;
                }

                $context->markConstraintAsValidated($cacheKey$constraintHash);
            }

            $context->setConstraint($constraint);

            $validator = $this->validatorFactory->getInstance($constraint);
            $validator->initialize($context);

            if ($value instanceof LazyProperty) {
                $value = $value->getPropertyValue();
            }

            
protected function validateConstraints($value$cache_key$constraints) {
    foreach ($constraints as $constraint) {
      // Prevent duplicate validation of constraints, in the case       // that constraints belong to multiple validated groups       if (isset($cache_key)) {
        $constraint_hash = spl_object_hash($constraint);

        if ($this->context->isConstraintValidated($cache_key$constraint_hash)) {
          continue;
        }

        $this->context->markConstraintAsValidated($cache_key$constraint_hash);
      }

      $this->context->setConstraint($constraint);

      $validator = $this->constraintValidatorFactory->getInstance($constraint);
      $validator->initialize($this->context);
      $validator->validate($value$constraint);
    }
  }

  /** * {@inheritdoc} */
Home | Imprint | This part of the site doesn't use cookies.