1 | <?php |
||
17 | class DatabaseUserProvider |
||
18 | { |
||
19 | |||
20 | use RedisTrait; |
||
21 | use IdGeneratorTrait; |
||
22 | use EventDispatcherTrait; |
||
23 | |||
24 | const REDIS_USER = 'user:%d'; |
||
25 | const REDIS_USER_NAMES = 'user_names'; |
||
26 | |||
27 | /** |
||
28 | * @var PasswordHasher |
||
29 | */ |
||
30 | private $hasher; |
||
31 | |||
32 | /** |
||
33 | * @var LoadUser |
||
34 | */ |
||
35 | private $loadUser; |
||
36 | |||
37 | /** |
||
38 | * @Inject({ |
||
39 | "@PasswordHasher", |
||
40 | "@Authentication.LoadUser", |
||
41 | * }) |
||
42 | * @param PasswordHasher $passwordHasher |
||
43 | * @param LoadUser $loadUser |
||
44 | */ |
||
45 | 13 | public function __construct(PasswordHasher $passwordHasher, LoadUser $loadUser) |
|
50 | |||
51 | /** |
||
52 | * @param string $username |
||
53 | * @return UserVO |
||
54 | * @deprecated use LoadUser |
||
55 | * @throws UsernameNotFoundException |
||
56 | */ |
||
57 | 1 | public function loadUserByUsername($username) |
|
61 | |||
62 | /** |
||
63 | * @param integer $userId |
||
64 | * @return UserVO |
||
65 | */ |
||
66 | 1 | public function loadUserById($userId) |
|
70 | |||
71 | /** |
||
72 | * @return string[] |
||
73 | */ |
||
74 | 1 | public function getAllUserNames() |
|
78 | |||
79 | /** |
||
80 | * @param string $password |
||
81 | * @return string $hash |
||
82 | */ |
||
83 | 3 | public function generateHash($password) |
|
87 | |||
88 | /** |
||
89 | * @param string $password |
||
90 | * @param string $hash |
||
91 | * @return boolean |
||
92 | */ |
||
93 | 1 | public function verifyHash($password, $hash) |
|
97 | |||
98 | /** |
||
99 | * @param UserVO $user |
||
100 | * @param string $newPassword |
||
101 | */ |
||
102 | 1 | public function changePassword(UserVO $user, $newPassword) |
|
109 | |||
110 | /** |
||
111 | * @param UserVO $userVo |
||
112 | * @param string $property |
||
113 | */ |
||
114 | 3 | public function setUserProperty(UserVO $userVo, $property) |
|
124 | |||
125 | /** |
||
126 | * @param UserVO $user |
||
127 | * @return integer $user_id |
||
128 | */ |
||
129 | 1 | public function register(UserVO $user) |
|
153 | |||
154 | /** |
||
155 | * @param integer $userId |
||
156 | */ |
||
157 | 2 | public function deleteUser($userId) |
|
172 | |||
173 | /** |
||
174 | * @param integer $userId |
||
175 | * @return string |
||
176 | */ |
||
177 | 5 | private function getKey($userId) |
|
181 | } |
||
182 |
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: