1 | <?php |
||
26 | class UserInformation implements UserInformationInterface |
||
27 | { |
||
28 | /** |
||
29 | * The contained data. |
||
30 | * |
||
31 | * @var array |
||
32 | */ |
||
33 | private $data = []; |
||
34 | |||
35 | /** |
||
36 | * The password salt. |
||
37 | * |
||
38 | * @var string |
||
39 | */ |
||
40 | private $salt; |
||
41 | |||
42 | /** |
||
43 | * Map for translating roles to array of strings and vice versa. |
||
44 | * |
||
45 | * @var string[] |
||
46 | */ |
||
47 | public static $roleMap = [ |
||
48 | UserInformationInterface::ROLE_NONE => 'ROLE_NONE', |
||
49 | UserInformationInterface::ROLE_UPGRADE => 'ROLE_UPGRADE', |
||
50 | UserInformationInterface::ROLE_MANIPULATE_REQUIREMENTS => 'ROLE_MANIPULATE_REQUIREMENTS', |
||
51 | UserInformationInterface::ROLE_EDIT_COMPOSER_JSON => 'ROLE_EDIT_COMPOSER_JSON', |
||
52 | UserInformationInterface::ROLE_EDIT_APPKERNEL => 'ROLE_EDIT_APP_KERNEL', |
||
53 | ]; |
||
54 | |||
55 | /** |
||
56 | * Constructor. |
||
57 | * |
||
58 | * @param array $data An array of values. |
||
59 | * |
||
60 | * @api |
||
61 | */ |
||
62 | public function __construct(array $data = []) |
||
70 | |||
71 | /** |
||
72 | * {@inheritDoc} |
||
73 | * |
||
74 | * @SuppressWarnings(PHPMD.CamelCaseVariableName) |
||
75 | */ |
||
76 | public function getRoles() |
||
91 | |||
92 | /** |
||
93 | * {@inheritDoc} |
||
94 | */ |
||
95 | public function getPassword() |
||
99 | |||
100 | /** |
||
101 | * Sets the password for this user instance. |
||
102 | * |
||
103 | * NOTE: the password must be encrypted. |
||
104 | * |
||
105 | * Example: |
||
106 | * $encoder = $container->get('security.password_encoder'); |
||
107 | * $encoded = $encoder->encodePassword($user, $plainPassword); |
||
108 | * $user->setPassword($encoded); |
||
109 | * |
||
110 | * @param string $encoded The encoded password. |
||
111 | * |
||
112 | * @return UserInformation |
||
113 | */ |
||
114 | public function setPassword($encoded) |
||
120 | |||
121 | /** |
||
122 | * {@inheritDoc} |
||
123 | */ |
||
124 | public function getSalt() |
||
128 | |||
129 | /** |
||
130 | * {@inheritDoc} |
||
131 | */ |
||
132 | public function getUsername() |
||
136 | |||
137 | /** |
||
138 | * {@inheritDoc} |
||
139 | */ |
||
140 | public function eraseCredentials() |
||
145 | |||
146 | /** |
||
147 | * Get the granted access levels. |
||
148 | * |
||
149 | * @return int |
||
150 | */ |
||
151 | public function getAccessLevel() |
||
155 | |||
156 | /** |
||
157 | * Set the granted access levels. |
||
158 | * |
||
159 | * @param int $accessLevel The granted access levels. |
||
160 | * |
||
161 | * @return UserInformation |
||
162 | */ |
||
163 | public function setAccessLevel($accessLevel) |
||
169 | |||
170 | /** |
||
171 | * {@inheritdoc} |
||
172 | */ |
||
173 | public function hasAccessLevel($accessLevel) |
||
177 | |||
178 | /** |
||
179 | * {@inheritdoc} |
||
180 | * |
||
181 | * @api |
||
182 | */ |
||
183 | public function keys() |
||
187 | |||
188 | /** |
||
189 | * {@inheritdoc} |
||
190 | * |
||
191 | * @api |
||
192 | */ |
||
193 | public function get($key, $default = null) |
||
207 | |||
208 | /** |
||
209 | * Sets a value by name. |
||
210 | * |
||
211 | * @param string $key The key. |
||
212 | * |
||
213 | * @param string|array $value The value. |
||
214 | * |
||
215 | * @return UserInformation |
||
216 | * |
||
217 | * @api |
||
218 | */ |
||
219 | public function set($key, $value) |
||
227 | |||
228 | /** |
||
229 | * {@inheritdoc} |
||
230 | * |
||
231 | * @api |
||
232 | */ |
||
233 | public function has($key) |
||
237 | |||
238 | /** |
||
239 | * Removes a value. |
||
240 | * |
||
241 | * @param string $key The value name. |
||
242 | * |
||
243 | * @return UserInformation |
||
244 | * |
||
245 | * @api |
||
246 | */ |
||
247 | public function remove($key) |
||
255 | |||
256 | /** |
||
257 | * {@inheritdoc} |
||
258 | */ |
||
259 | public function values() |
||
269 | |||
270 | /** |
||
271 | * String representation of this user information for use in logs. |
||
272 | * |
||
273 | * Examples may be: "user foo" or "token 0123456789". |
||
274 | * |
||
275 | * @return string |
||
276 | */ |
||
277 | public function asString() |
||
281 | } |
||
282 |