Class frontend\models\VerifyEmailForm
| Inheritance | frontend\models\VerifyEmailForm » yii\base\Model |
|---|---|
| Source Code | https://github.com/yiisoft/yii2-app-advanced/blob/master/frontend/models/VerifyEmailForm.php |
Public Properties
| Property | Type | Description | Defined By |
|---|---|---|---|
| $token | string | frontend\models\VerifyEmailForm |
Public Methods
| Method | Description | Defined By |
|---|---|---|
| __construct() | Creates a form model with given token. | frontend\models\VerifyEmailForm |
| verifyEmail() | Verify email | frontend\models\VerifyEmailForm |
Property Details
Method Details
Creates a form model with given token.
| public mixed __construct ( string $token, array $config = [] ) | ||
| $token | string | |
| $config | array |
Name-value pairs that will be used to initialize the object properties |
| throws | \yii\base\InvalidArgumentException |
if token is empty or not valid |
|---|---|---|
public function __construct($token, array $config = [])
{
if (empty($token) || !is_string($token)) {
throw new InvalidArgumentException('Verify email token cannot be blank.');
}
$this->_user = User::findByVerificationToken($token);
if (!$this->_user) {
throw new InvalidArgumentException('Wrong verify email token.');
}
parent::__construct($config);
}
Verify email
| public common\models\User|null verifyEmail ( ) | ||
| return | common\models\User|null |
The saved model or null if saving fails |
|---|---|---|
public function verifyEmail()
{
$user = $this->_user;
$user->status = User::STATUS_ACTIVE;
return $user->save(false) ? $user : null;
}