1 | <?php |
||
13 | class SignupProviderForm extends \yii\base\Model |
||
14 | { |
||
15 | /** |
||
16 | * @var int |
||
17 | */ |
||
18 | public $type; |
||
19 | /** |
||
20 | * @var string |
||
21 | */ |
||
22 | public $email; |
||
23 | /** |
||
24 | * @var \app\models\User |
||
25 | */ |
||
26 | private $user = null; |
||
27 | /** |
||
28 | * @var bool |
||
29 | */ |
||
30 | private $verified = false; |
||
31 | /** |
||
32 | * @var array |
||
33 | */ |
||
34 | private $data = []; |
||
35 | |||
36 | /** |
||
37 | * Form for social auth |
||
38 | * |
||
39 | * @param array $data |
||
40 | * @param array $config |
||
41 | */ |
||
42 | public function __construct($data, $config = []) |
||
43 | { |
||
44 | $this->email = ArrayHelper::getValue($data['profile'], 'email'); |
||
45 | $this->type = $data['type']; |
||
46 | $this->data = $data; |
||
47 | |||
48 | if (ArrayHelper::getValue($data['profile'], 'verified') && !empty($this->email)) { |
||
49 | $this->verified = true; |
||
50 | $this->user = User::findByEmail($this->email); |
||
51 | |||
52 | if (!$this->user) { |
||
53 | $this->user = new User(); |
||
54 | $this->user->setConfirmed(); |
||
55 | } |
||
56 | } |
||
57 | |||
58 | if ($this->user === null) { |
||
59 | $this->user = new User(); |
||
60 | } |
||
61 | |||
62 | parent::__construct($config); |
||
63 | } |
||
64 | |||
65 | /** |
||
66 | * @inheritdoc |
||
67 | */ |
||
68 | public function rules() |
||
81 | |||
82 | /** |
||
83 | * @inheritdoc |
||
84 | */ |
||
85 | public function attributeLabels() |
||
89 | |||
90 | /** |
||
91 | * Is verified? |
||
92 | * |
||
93 | * @return bool |
||
94 | */ |
||
95 | public function isVerified() |
||
99 | |||
100 | /** |
||
101 | * Save photo |
||
102 | * |
||
103 | * @param \app\models\UserProfile $profile |
||
104 | * @param string $photo |
||
105 | * @return void |
||
106 | */ |
||
107 | private function savePhoto($profile, $photo) |
||
120 | |||
121 | /** |
||
122 | * Signs user up |
||
123 | * |
||
124 | * @param bool $validate |
||
125 | * @return \app\models\User |
||
126 | */ |
||
127 | public function signup($validate = true) |
||
150 | |||
151 | /** |
||
152 | * Sends an email with a link, for confirm the email |
||
153 | * |
||
154 | * @return boolean |
||
155 | */ |
||
156 | public function sendEmail() |
||
173 | } |
||
174 |
If you implement
__call
and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.This is often the case, when
__call
is implemented by a parent class and only the child class knows which methods exist: