/** * @param ElementInterface $element * @param boolean $block * * @return null|string */ public function __invoke(ElementInterface $element, $block = false) { $messages = $element->getMessages(); if (empty($messages)) { return null; } $errors = array(); foreach ($messages as $message) { $error = new HtmlElement('span'); $error->addClass($block ? 'help-block' : 'help-inline'); $error->setContent($this->translate((string) $message)); $errors[] = $error; } return implode(PHP_EOL, $errors); }
/** * Set the content of the element * * @param string $content * * @return $this */ public function setContent($content) { $this->element->setContent($content); return $this; }
public function testGetContent() { $htmlElement = new HtmlElement(); $htmlElement->setContent('Where did you go?'); $this->assertEquals('Where did you go?', $htmlElement->getContent()); }