本文整理汇总了PHP中yii\captcha\Captcha::checkRequirements方法的典型用法代码示例。如果您正苦于以下问题:PHP Captcha::checkRequirements方法的具体用法?PHP Captcha::checkRequirements怎么用?PHP Captcha::checkRequirements使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类yii\captcha\Captcha
的用法示例。
在下文中一共展示了Captcha::checkRequirements方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: renderImage
/**
* Renders the CAPTCHA image.
* @param string $code the verification code
* @return string image contents
*/
protected function renderImage($code)
{
if (Captcha::checkRequirements() === 'gd') {
return $this->renderImageByGD($code);
} else {
return $this->renderImageByImagick($code);
}
}
示例2: renderImage
/**
* Renders the CAPTCHA image.
* @param string $code the verification code
* @return string image contents
* @throws InvalidConfigException if imageLibrary is not supported
*/
protected function renderImage($code)
{
if (isset($this->imageLibrary)) {
$imageLibrary = $this->imageLibrary;
} else {
$imageLibrary = Captcha::checkRequirements();
}
if ($imageLibrary === 'gd') {
return $this->renderImageByGD($code);
} elseif ($imageLibrary === 'imagick') {
return $this->renderImageByImagick($code);
} else {
throw new InvalidConfigException("Defined library '{$imageLibrary}' is not supported");
}
}
示例3: createFormModel
/**
* A factory to create pre-configured form models. Only model class names
* from the nineinchnick\usr\models namespace are allowed.
* Sets scenario, password strength rules for models extending BasePasswordForm and attaches behaviors.
*
* @param string $class without the namespace
* @param string $scenario
* @return Model
*/
public function createFormModel($class, $scenario = null)
{
$namespacedClass = "\\nineinchnick\\usr\\models\\{$class}";
/** @var Model */
$form = new $namespacedClass();
if ($scenario !== null) {
$form->setScenario($scenario);
}
if ($form instanceof \nineinchnick\usr\models\BaseUsrForm) {
$form->webUser = Yii::$app->user;
}
if ($form instanceof \nineinchnick\usr\models\BasePasswordForm) {
$form->passwordStrengthRules = $this->passwordStrengthRules;
}
switch ($class) {
default:
break;
case 'ProfileForm':
$form->pictureUploadRules = $this->pictureUploadRules;
if (!empty($this->profileFormBehaviors)) {
foreach ($this->profileFormBehaviors as $name => $config) {
$form->attachBehavior($name, $config);
}
}
// no break
// no break
case 'RecoveryForm':
if ($this->captcha !== null && \yii\captcha\Captcha::checkRequirements()) {
$form->attachBehavior('captcha', ['class' => 'nineinchnick\\usr\\components\\CaptchaFormBehavior', 'ruleOptions' => $class == 'ProfileForm' ? ['on' => 'register'] : ['except' => ['reset', 'verify']]]);
}
break;
case 'LoginForm':
if ($this->loginFormBehaviors !== null && is_array($this->loginFormBehaviors)) {
foreach ($this->loginFormBehaviors as $name => $config) {
$form->attachBehavior($name, $config);
}
}
break;
case 'AuthForm':
$form->setValidProviders(array_keys(Yii::$app->get('authClientCollection')->clients));
break;
}
return $form;
}
示例4: rules
public function rules()
{
return array([['username'], 'required', 'message' => '请输入用户名'], [['username'], 'required', 'message' => '请输入密码'], [['username'], 'checkUserNameAndPassword'], [['password'], 'checkUserNameAndPassword'], [['verifyCode'], 'captcha', 'skipOnEmpty' => !Captcha::checkRequirements(), 'message' => '验证码不正确']);
}