function PrecedingConstraintAwareValidatorTrait::getPrecedingConstraints

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

Gets the constraints preceding the given constraint in the current context.

Parameters

\Symfony\Component\Validator\Constraint $needle: The constraint to find the preceding constraints for.

Return value

iterable The preceding constraints.

1 call to PrecedingConstraintAwareValidatorTrait::getPrecedingConstraints()
PrecedingConstraintAwareValidatorTrait::hasViolationsForPrecedingConstraints in core/modules/ckeditor5/src/Plugin/Validation/Constraint/PrecedingConstraintAwareValidatorTrait.php
Checks whether any preceding constraints have been violated.

File

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

Class

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

Namespace

Drupal\ckeditor5\Plugin\Validation\Constraint

Code

private function getPrecedingConstraints(Constraint $needle) : iterable {
    assert($this->context instanceof ExecutionContext);
    $constraints = $this->context
        ->getMetadata()
        ->getConstraints();
    if (!in_array($needle, $constraints)) {
        throw new \OutOfBoundsException();
    }
    foreach ($constraints as $constraint) {
        if ($constraint != $needle) {
            (yield $constraint);
        }
    }
}

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