1 | <?php |
||
23 | class UserProvider implements UserProviderInterface |
||
24 | { |
||
25 | |||
26 | /** |
||
27 | * The Entity fieldname of the username. |
||
28 | */ |
||
29 | protected $usernameField; |
||
30 | |||
31 | /** |
||
32 | * The fieldname of the password (hash). |
||
33 | */ |
||
34 | protected $passwordField; |
||
35 | |||
36 | /** |
||
37 | * The fieldname of the password hash salt. |
||
38 | */ |
||
39 | protected $saltField; |
||
40 | |||
41 | /** |
||
42 | * Holds the AbstractData instance to grab the user data from. |
||
43 | */ |
||
44 | protected $userData; |
||
45 | |||
46 | /** |
||
47 | * Holds the AbstractData instance or the field of the many-to-many relationship to grab the user role data from. |
||
48 | */ |
||
49 | protected $userRoleData; |
||
50 | |||
51 | /** |
||
52 | * Holds the AbstractData instance or the field of the many-to-many relationship to grab the user role data from. |
||
53 | */ |
||
54 | protected $userRoleIdentifier; |
||
55 | |||
56 | /** |
||
57 | * Loads the roles of an user via an AbstractData instance. |
||
58 | * |
||
59 | * @param mixed $userId |
||
60 | * the id of the user |
||
61 | * |
||
62 | * @return string[] |
||
63 | * the roles of the user |
||
64 | */ |
||
65 | protected function loadUserRolesViaData($userId) |
||
77 | |||
78 | /** |
||
79 | * Loads the roles of an user via a many-to-many relationship |
||
80 | * |
||
81 | * @param Entity $user |
||
82 | * the id of the user |
||
83 | * |
||
84 | * @return string[] |
||
85 | * the roles of the user |
||
86 | */ |
||
87 | protected function loadUserRolesViaManyToMany($user) |
||
97 | |||
98 | /** |
||
99 | * Constructor for data structures connecting users and roles via a many-to-many relationship on the user. |
||
100 | * |
||
101 | * @param Service $service |
||
102 | * the Service instance to take the AbstractData of the users from |
||
103 | * |
||
104 | * @param string $userIdentifier |
||
105 | * the identifier to of the user AbstractData |
||
106 | * |
||
107 | * @param string $userRoleIdentifier |
||
108 | * the field of the many-to-many relationship to grab the user role data from or the AbstractData if its an own entity |
||
109 | * |
||
110 | * @param string $usernameField |
||
111 | * the Entity fieldname of the username |
||
112 | * |
||
113 | * @param string $passwordField |
||
114 | * the Entity fieldname of the password hash |
||
115 | * |
||
116 | * @param string $saltField |
||
117 | * the Entity fieldname of the password hash salt |
||
118 | */ |
||
119 | public function __construct(Service $service, $userIdentifier = 'user', $userRoleIdentifier = 'roles', $usernameField = 'username', $passwordField = 'password', $saltField = 'salt') |
||
127 | |||
128 | /** |
||
129 | * Loads and returns an user by username. |
||
130 | * Throws an UsernameNotFoundException on not existing username. |
||
131 | * |
||
132 | * @param string $username |
||
133 | * the username |
||
134 | * |
||
135 | * @return User |
||
136 | * the loaded user |
||
137 | */ |
||
138 | public function loadUserByUsername($username) |
||
152 | |||
153 | /** |
||
154 | * Reloads and returns the given user. |
||
155 | * Throws an UsernameNotFoundException if the user ceased to exist meanwhile. |
||
156 | * |
||
157 | * @param UserInterface $user |
||
158 | * the user to reload |
||
159 | * |
||
160 | * @return User |
||
161 | * the reloaded user |
||
162 | */ |
||
163 | public function refreshUser(UserInterface $user) |
||
168 | |||
169 | /** |
||
170 | * Tests whether the given user class is supported by this UserProvider. |
||
171 | * |
||
172 | * @param string $class |
||
173 | * the user class name to test |
||
174 | * |
||
175 | * @return boolean |
||
176 | * true if the class is "CRUDlex\User" |
||
177 | */ |
||
178 | public function supportsClass($class) |
||
182 | |||
183 | } |
||
184 |
Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.