1 | <?php |
||
33 | class User extends Model implements IdentityInterface |
||
34 | { |
||
35 | public $id; |
||
36 | public $email; |
||
37 | public $username; |
||
38 | public $type; |
||
39 | public $seller; |
||
40 | public $seller_id; |
||
41 | public $last_name; |
||
42 | public $first_name; |
||
43 | |||
44 | public $auth_key; |
||
45 | public $password_hash; |
||
46 | |||
47 | private static $_users = []; |
||
48 | |||
49 | public function save() |
||
54 | |||
55 | public static function findOne($id) |
||
63 | |||
64 | /** |
||
65 | * {@inheritdoc} |
||
66 | */ |
||
67 | public function rules() |
||
77 | |||
78 | /** {@inheritdoc} */ |
||
79 | public static function findIdentity($id) |
||
83 | |||
84 | /** {@inheritdoc} */ |
||
85 | public function getAccessToken() |
||
92 | |||
93 | /** |
||
94 | * {@inheritdoc} |
||
95 | */ |
||
96 | public static function findIdentityByAccessToken($token, $type = null) |
||
100 | |||
101 | /** |
||
102 | * Finds user by username. |
||
103 | * |
||
104 | * @param string $username |
||
105 | * @return static|null |
||
106 | */ |
||
107 | public static function findByUsername($username) |
||
111 | |||
112 | /** |
||
113 | * Finds user by password reset token. |
||
114 | * |
||
115 | * @param string $token password reset token |
||
116 | * @return static|null |
||
117 | */ |
||
118 | public static function findByPasswordResetToken($token) |
||
129 | |||
130 | /** |
||
131 | * Finds out if password reset token is valid. |
||
132 | * |
||
133 | * @param string $token password reset token |
||
134 | * @return boolean |
||
135 | */ |
||
136 | public static function isPasswordResetTokenValid($token) |
||
146 | |||
147 | /** |
||
148 | * {@inheritdoc} |
||
149 | */ |
||
150 | public function getId() |
||
154 | |||
155 | public function is($key) |
||
159 | |||
160 | public function not($key) |
||
164 | |||
165 | public function getLogin() |
||
169 | |||
170 | public function getName() |
||
174 | |||
175 | /** |
||
176 | * {@inheritdoc} |
||
177 | */ |
||
178 | public function getAuthKey() |
||
183 | |||
184 | /** |
||
185 | * {@inheritdoc} |
||
186 | */ |
||
187 | public function validateAuthKey($authKey) |
||
191 | |||
192 | /** |
||
193 | * Validates password. |
||
194 | * |
||
195 | * @param string $password password to validate |
||
196 | * @return boolean if password provided is valid for current user |
||
197 | */ |
||
198 | public function validatePassword($password) |
||
202 | |||
203 | /** |
||
204 | * Generates password hash from password and sets it to the model. |
||
205 | * |
||
206 | * @param string $password |
||
207 | */ |
||
208 | public function setPassword($password) |
||
212 | |||
213 | /** |
||
214 | * Generates "remember me" authentication key. |
||
215 | */ |
||
216 | public function generateAuthKey() |
||
221 | |||
222 | /** |
||
223 | * Generates new password reset token. |
||
224 | */ |
||
225 | public function generatePasswordResetToken() |
||
229 | |||
230 | /** |
||
231 | * Removes password reset token. |
||
232 | */ |
||
233 | public function removePasswordResetToken() |
||
237 | } |
||
238 |
Let’s assume you have a class which uses late-static binding:
The code above will run fine in your PHP runtime. However, if you now create a sub-class and call the
getSomeVariable()
on that sub-class, you will receive a runtime error:In the case above, it makes sense to update
SomeClass
to useself
instead: