function EntityConstraintViolationList::findByCodes

Same name in other branches
  1. 10 core/lib/Drupal/Core/Entity/EntityConstraintViolationList.php \Drupal\Core\Entity\EntityConstraintViolationList::findByCodes()

Overrides EntityConstraintViolationListInterface::findByCodes

File

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

Class

EntityConstraintViolationList
Implements an entity constraint violation list.

Namespace

Drupal\Core\Entity

Code

public function findByCodes(string|array $codes) : static {
    $violations = [];
    foreach ($this as $violation) {
        if (in_array($violation->getCode(), $codes, TRUE)) {
            $violations[] = $violation;
        }
    }
    return new static($this->getEntity(), $violations);
}

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