public function __invoke(FormErrorSequence $errors, array $htmlAttributes = []) : string { if ($errors->isEmpty()) { return ''; } $errorFormatter = $this->errorFormatter; $document = new DOMDocument('1.0', 'utf-8'); $list = $document->createElement('ul'); $document->appendChild($list); $this->addAttributes($list, $htmlAttributes); foreach ($errors as $error) { /* @var $error FormError */ $list->appendChild($document->createElement('li', htmlspecialchars($errorFormatter($error->getMessage(), $error->getArguments())))); } return $document->saveHTML($list); }
public function hasErrors() : bool { return !$this->errors->isEmpty(); }