function PrecedingConstraintAwareValidatorTrait::hasViolationsForPrecedingConstraints

Same name in other branches
  1. 10 core/modules/ckeditor5/src/Plugin/Validation/Constraint/PrecedingConstraintAwareValidatorTrait.php \Drupal\ckeditor5\Plugin\Validation\Constraint\PrecedingConstraintAwareValidatorTrait::hasViolationsForPrecedingConstraints()
  2. 11.x core/modules/ckeditor5/src/Plugin/Validation/Constraint/PrecedingConstraintAwareValidatorTrait.php \Drupal\ckeditor5\Plugin\Validation\Constraint\PrecedingConstraintAwareValidatorTrait::hasViolationsForPrecedingConstraints()

Checks whether any preceding constraints have been violated.

Parameters

\Symfony\Component\Validator\Constraint $current_constraint: The constraint currently being validated.

Return value

bool TRUE if any preceding constraints have been violated, FALSE otherwise.

1 call to PrecedingConstraintAwareValidatorTrait::hasViolationsForPrecedingConstraints()
StyleSensibleElementConstraintValidator::validate in core/modules/ckeditor5/src/Plugin/Validation/Constraint/StyleSensibleElementConstraintValidator.php

File

core/modules/ckeditor5/src/Plugin/Validation/Constraint/PrecedingConstraintAwareValidatorTrait.php, line 27

Class

PrecedingConstraintAwareValidatorTrait
A constraint may need preceding constraints to not have been violated.

Namespace

Drupal\ckeditor5\Plugin\Validation\Constraint

Code

protected function hasViolationsForPrecedingConstraints(Constraint $current_constraint) : bool {
    assert($this->context instanceof ExecutionContext);
    $earlier_constraints = iterator_to_array($this->getPrecedingConstraints($current_constraint));
    $earlier_violations = array_filter(iterator_to_array($this->context
        ->getViolations()), function (ConstraintViolationInterface $violation) use ($earlier_constraints) {
        return in_array($violation->getConstraint(), $earlier_constraints);
    });
    return !empty($earlier_violations);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.