function EntityConstraintViolationList::findByCodes
Same name and namespace in other branches
- 11.x core/lib/Drupal/Core/Entity/EntityConstraintViolationList.php \Drupal\Core\Entity\EntityConstraintViolationList::findByCodes()
Filters this violation list by the given error codes.
Copied from Symfony parent class \Symfony\Component\Validator\ConstraintViolationList.
Parameters
string|string[] $codes: The codes to find.
Return value
\Drupal\Core\Entity\EntityConstraintViolationListInterface A list of violations of the given fields.
Overrides EntityConstraintViolationListInterface::findByCodes
File
-
core/
lib/ Drupal/ Core/ Entity/ EntityConstraintViolationList.php, line 176
Class
- EntityConstraintViolationList
- Implements an entity constraint violation list.
Namespace
Drupal\Core\EntityCode
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.