Symfony\Component\Validator\ConstraintViolationList::__construct PHP Method

__construct() public method

Creates a new constraint violation list.
public __construct ( array $violations = [] )
$violations array The constraint violations to add to the list
    public function __construct(array $violations = array())
    {
        foreach ($violations as $violation) {
            $this->add($violation);
        }
    }

Usage Example

 /**
  * {@inheritdoc}
  *
  * @param \Drupal\Core\Entity\FieldableEntityInterface $entity
  *   The entity that has been validated.
  * @param array $violations
  *   The array of violations.
  */
 public function __construct(FieldableEntityInterface $entity, array $violations = array())
 {
     parent::__construct($violations);
     $this->entity = $entity;
 }