X-Git-Url: http://www.aleph1.co.uk/gitweb/?a=blobdiff_plain;ds=sidebyside;f=vendor%2Fsymfony%2Fvalidator%2FConstraintViolationList.php;fp=vendor%2Fsymfony%2Fvalidator%2FConstraintViolationList.php;h=a80d602b26fd96e10ec46c40218f7cd843bc71d2;hb=af6d1fb995500ae68849458ee10d66abbdcfb252;hp=3490237bc2d6b443fde05c4979e1e75839ab4b62;hpb=680c79a86e3ed402f263faeac92e89fb6d9edcc0;p=yaffs-website diff --git a/vendor/symfony/validator/ConstraintViolationList.php b/vendor/symfony/validator/ConstraintViolationList.php index 3490237bc..a80d602b2 100644 --- a/vendor/symfony/validator/ConstraintViolationList.php +++ b/vendor/symfony/validator/ConstraintViolationList.php @@ -158,4 +158,24 @@ class ConstraintViolationList implements \IteratorAggregate, ConstraintViolation { $this->remove($offset); } + + /** + * Creates iterator for errors with specific codes. + * + * @param string|string[] $codes The codes to find + * + * @return static new instance which contains only specific errors + */ + public function findByCodes($codes) + { + $codes = (array) $codes; + $violations = array(); + foreach ($this as $violation) { + if (in_array($violation->getCode(), $codes, true)) { + $violations[] = $violation; + } + } + + return new static($violations); + } }