Total Complexity | 6 |
Total Lines | 41 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
13 | class EmailConfirmForm extends Model |
||
14 | { |
||
15 | /** |
||
16 | * @var \modules\users\models\User|bool |
||
17 | */ |
||
18 | private $_user; |
||
19 | |||
20 | /** |
||
21 | * Creates a form model given a token. |
||
22 | * |
||
23 | * @param mixed $token |
||
24 | * @param array $config |
||
25 | * @throws \yii\base\InvalidArgumentException if token is empty or not valid |
||
26 | */ |
||
27 | public function __construct($token = '', $config = []) |
||
28 | { |
||
29 | if (empty($token) || !is_string($token)) { |
||
30 | throw new InvalidArgumentException(Module::t('module', 'Email confirm token cannot be blank.')); |
||
31 | } |
||
32 | $this->_user = User::findByEmailConfirmToken($token); |
||
33 | if (!$this->_user) { |
||
34 | throw new InvalidArgumentException(Module::t('module', 'Wrong Email confirm token.')); |
||
35 | } |
||
36 | parent::__construct($config); |
||
37 | } |
||
38 | |||
39 | /** |
||
40 | * Confirm email. |
||
41 | * |
||
42 | * @return bool|\yii\rbac\Assignment if email was confirmed. |
||
43 | * @throws \Exception |
||
44 | */ |
||
45 | public function confirmEmail() |
||
54 | } |
||
55 | } |
||
56 |