/** * Validate control. Do not call directly! * @param CaptchaControl * @return bool * @throws \Nette\InvalidStateException */ public function validateCaptcha(CaptchaControl $control) { $parent = $control->getParent(); $uidFieldName = $control->getUidFieldName(); if (!isset($parent[$uidFieldName])) { throw new \Nette\InvalidStateException('Can\'t find ' . __CLASS__ . ' uid field ' . $uidFieldName . ' in parent'); } $uid = $parent[$uidFieldName]->getValue(); $sessionValue = $control->getSession($uid); $control->unsetSession($uid); return $sessionValue === $control->getValue(); }