Commit 0c1477c6 by Qiang Xue

Fixes #1050: renamed CaptchaValidator::getCaptchaAction() to createCaptchaAction().

parent 6c6dd011
...@@ -18,8 +18,6 @@ use yii\validators\Validator; ...@@ -18,8 +18,6 @@ use yii\validators\Validator;
* *
* CaptchaValidator should be used together with [[CaptchaAction]]. * CaptchaValidator should be used together with [[CaptchaAction]].
* *
* @property \yii\captcha\CaptchaAction $captchaAction The action object. This property is read-only.
*
* @author Qiang Xue <qiang.xue@gmail.com> * @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0 * @since 2.0
*/ */
...@@ -71,16 +69,16 @@ class CaptchaValidator extends Validator ...@@ -71,16 +69,16 @@ class CaptchaValidator extends Validator
*/ */
public function validateValue($value) public function validateValue($value)
{ {
$captcha = $this->getCaptchaAction(); $captcha = $this->createCaptchaAction();
return !is_array($value) && $captcha->validate($value, $this->caseSensitive); return !is_array($value) && $captcha->validate($value, $this->caseSensitive);
} }
/** /**
* Returns the CAPTCHA action object. * Creates the CAPTCHA action object from the route specified by [[captchaAction]].
* @throws InvalidConfigException
* @return \yii\captcha\CaptchaAction the action object * @return \yii\captcha\CaptchaAction the action object
* @throws InvalidConfigException
*/ */
public function getCaptchaAction() public function createCaptchaAction()
{ {
$ca = Yii::$app->createController($this->captchaAction); $ca = Yii::$app->createController($this->captchaAction);
if ($ca !== false) { if ($ca !== false) {
...@@ -104,7 +102,7 @@ class CaptchaValidator extends Validator ...@@ -104,7 +102,7 @@ class CaptchaValidator extends Validator
*/ */
public function clientValidateAttribute($object, $attribute, $view) public function clientValidateAttribute($object, $attribute, $view)
{ {
$captcha = $this->getCaptchaAction(); $captcha = $this->createCaptchaAction();
$code = $captcha->getVerifyCode(false); $code = $captcha->getVerifyCode(false);
$hash = $captcha->generateValidationHash($this->caseSensitive ? $code : strtolower($code)); $hash = $captcha->generateValidationHash($this->caseSensitive ? $code : strtolower($code));
$options = [ $options = [
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment