3 * Zend Framework (http://framework.zend.com/)
5 * @link http://github.com/zendframework/zf2 for the canonical source repository
6 * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
7 * @license http://framework.zend.com/license/new-bsd New BSD License
10 namespace Zend\Form\View\Helper\Captcha
;
12 use Zend\Captcha\Figlet
as CaptchaAdapter
;
13 use Zend\Form\ElementInterface
;
14 use Zend\Form\Exception
;
16 class Figlet
extends AbstractWord
21 * @param ElementInterface $element
22 * @throws Exception\DomainException
25 public function render(ElementInterface
$element)
27 $captcha = $element->getCaptcha();
29 if ($captcha === null ||
!$captcha instanceof CaptchaAdapter
) {
30 throw new Exception\
DomainException(sprintf(
31 '%s requires that the element has a "captcha" attribute of type Zend\Captcha\Figlet; none found',
40 $captcha->getFiglet()->render($captcha->getWord())
43 $position = $this->getCaptchaPosition();
44 $separator = $this->getSeparator();
45 $captchaInput = $this->renderCaptchaInputs($element);
48 if ($position == self
::CAPTCHA_PREPEND
) {
49 return sprintf($pattern, $captchaInput, $separator, $figlet);
52 return sprintf($pattern, $figlet, $separator, $captchaInput);