/** * {@inheritdoc} */ public function buildView(FormView $view, FormInterface $form, array $options) { $sessionKey = sprintf('%s_zend_captcha_session_key_%s', $form->getParent()->getName(), $form->getName()); $captcha = new Image(); if (isset($options['suffix'])) { $captcha->setSuffix($options['suffix']); } if (isset($options['height'])) { $captcha->setHeight($options['height']); } if (isset($options['width'])) { $captcha->setWidth($options['width']); } if (isset($options['img_alt'])) { $captcha->setImgAlt($options['img_alt']); } if (isset($options['font_size'])) { $captcha->setFontSize($options['font_size']); } if (isset($options['dot_noise_level'])) { $captcha->setDotNoiseLevel($options['dot_noise_level']); } if (isset($options['line_noise_level'])) { $captcha->setLineNoiseLevel($options['line_noise_level']); } if (isset($options['word_len'])) { $captcha->setWordlen($options['word_len']); } if (isset($options['expiration'])) { $captcha->setExpiration($options['expiration']); } if (isset($options['gc_freq'])) { $captcha->setGcFreq($options['gc_freq']); } $captcha->setImgDir($this->options['img_dir']); $captcha->setFont($this->options['font']); $captcha->setImgUrl($this->options['img_url']); $captcha->getWord(); $captcha->generate(); $this->session->set($sessionKey, $captcha->getSession()->getName()); $view->vars = array_merge($view->vars, array('img_url' => $captcha->getImgUrl() . $captcha->getId() . $captcha->getSuffix(), 'height' => $captcha->getHeight(), 'width' => $captcha->getWidth(), 'img_alt' => $captcha->getImgAlt(), 'img_id' => $captcha->getId(), 'value' => "")); }