public function buildView(FormViewInterface $view, FormInterface $form, array $options) { $fingerprint = null; if ($options['keep_value'] && $this->session->has($this->key . '_fingerprint')) { $fingerprint = $this->session->get($this->key . '_fingerprint'); } $generator = new CaptchaGenerator($this->generateCaptchaValue(), $options['image_folder'], $options['web_path'], $options['gc_freq'], $options['expiration'], $options['font'], $fingerprint, $options['quality']); if ($options['as_file']) { $captchaCode = $generator->getFile($options['width'], $options['height']); } else { $captchaCode = $generator->getCode($options['width'], $options['height']); } if ($options['keep_value']) { $this->session->set($this->key . '_fingerprint', $generator->getFingerprint()); } $view->addVars(array('captcha_width' => $options['width'], 'captcha_height' => $options['height'], 'captcha_code' => $captchaCode, 'value' => '')); }
public function buildView(FormView $view, FormInterface $form) { $fingerprint = null; if ($this->session->has($this->key . '_fingerprint')) { $fingerprint = $this->session->get($this->key . '_fingerprint'); } $generator = new CaptchaGenerator($this->generateCaptchaValue(), $this->imageFolder, $this->webPath, $this->gcFreq, $this->expiration, $this->font, $fingerprint, $this->quality); if ($this->asFile) { $view->set('captcha_code', $generator->getFile($this->width, $this->height)); } else { $view->set('captcha_code', $generator->getCode($this->width, $this->height)); } $view->set('captcha_width', $this->width); $view->set('captcha_height', $this->height); if ($this->keepValue) { $this->session->set($this->key . '_fingerprint', $generator->getFingerprint()); } $view->set('value', ''); }