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

getIterator() public method

See also: IteratorAggregate
public getIterator ( )
    public function getIterator()
    {
        return new \ArrayIterator($this->violations);
    }

Usage Example

 /**
  * Get the validation errors
  *
  * @param ConstraintViolationList $errors Validator error list
  *
  * @return View
  */
 protected function getErrorsView(ConstraintViolationList $errors)
 {
     $msgs = array();
     $errorIterator = $errors->getIterator();
     foreach ($errorIterator as $validationError) {
         $msg = $validationError->getMessage();
         $params = $validationError->getMessageParameters();
         $msgs[][] = $this->get('translator')->trans($msg, $params, 'validators');
     }
     $view = View::create($msgs);
     $view->setStatusCode(400);
     return $view;
 }
All Usage Examples Of Symfony\Component\Validator\ConstraintViolationList::getIterator