function EntityConstraintViolationList::getByFields

Same name in other branches
  1. 8.9.x core/lib/Drupal/Core/Entity/EntityConstraintViolationList.php \Drupal\Core\Entity\EntityConstraintViolationList::getByFields()
  2. 10 core/lib/Drupal/Core/Entity/EntityConstraintViolationList.php \Drupal\Core\Entity\EntityConstraintViolationList::getByFields()
  3. 11.x core/lib/Drupal/Core/Entity/EntityConstraintViolationList.php \Drupal\Core\Entity\EntityConstraintViolationList::getByFields()

Overrides EntityConstraintViolationListInterface::getByFields

1 call to EntityConstraintViolationList::getByFields()
EntityConstraintViolationList::getByField in core/lib/Drupal/Core/Entity/EntityConstraintViolationList.php
Gets the violations of the given field.

File

core/lib/Drupal/Core/Entity/EntityConstraintViolationList.php, line 106

Class

EntityConstraintViolationList
Implements an entity constraint violation list.

Namespace

Drupal\Core\Entity

Code

public function getByFields(array $field_names) {
    $this->groupViolationOffsets();
    $violations = [];
    foreach (array_intersect_key($this->violationOffsetsByField, array_flip($field_names)) as $offsets) {
        foreach ($offsets as $offset) {
            $violations[] = $this->get($offset);
        }
    }
    return new static($this->entity, $violations);
}

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