yii\captcha\CaptchaAction::getVerifyCode PHP Метод

getVerifyCode() публичный Метод

Gets the verification code.
public getVerifyCode ( boolean $regenerate = false ) : string
$regenerate boolean whether the verification code should be regenerated.
Результат string the verification code.
    public function getVerifyCode($regenerate = false)
    {
        if ($this->fixedVerifyCode !== null) {
            return $this->fixedVerifyCode;
        }
        $session = Yii::$app->getSession();
        $session->open();
        $name = $this->getSessionKey();
        if ($session[$name] === null || $regenerate) {
            $session[$name] = $this->generateVerifyCode();
            $session[$name . 'count'] = 1;
        }
        return $session[$name];
    }

Usage Example

Пример #1
0
 public function getVerifyCode($regenerate = false)
 {
     if (!$this->regenerateIfAjax) {
         $request = Yii::$app->getRequest();
         if ($request->getIsAjax() && !$request->getQueryParam(self::REFRESH_GET_VAR)) {
             $regenerate = false;
         }
     }
     return parent::getVerifyCode($regenerate);
 }