/** * Validation of given Params * * @param \In2code\Powermail\Domain\Model\Mail $mail * @return bool */ public function isValid($mail) { if (!$this->formHasCaptcha($mail->getForm())) { return TRUE; } foreach ($mail->getAnswers() as $answer) { if ($answer->getField()->getType() !== 'captcha') { continue; } $this->captchaArgumentFound = TRUE; if (!$this->captchaEngine->validCode($answer->getValue(), $this->clearSession)) { $this->setErrorAndMessage($answer->getField(), 'captcha'); } } // if no captcha arguments given (maybe deleted from DOM) if (!$this->captchaArgumentFound) { $this->addError('captcha', 0); $this->setIsValid(FALSE); } return $this->getIsValid(); }
/** * Returns Captcha-Image String * * @return string HTML-Tag for Captcha image */ public function render() { $this->captchaEngine->setConfiguration($this->settings); return $this->captchaEngine->render(); }