1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* UserService class. |
5
|
|
|
* |
6
|
|
|
* @copyright Copyright (C) eZ Systems AS. All rights reserved. |
7
|
|
|
* @license For full copyright and license information view LICENSE file distributed with this source code. |
8
|
|
|
*/ |
9
|
|
|
namespace eZ\Publish\Core\SignalSlot; |
10
|
|
|
|
11
|
|
|
use eZ\Publish\API\Repository\UserService as UserServiceInterface; |
12
|
|
|
use eZ\Publish\API\Repository\Values\Content\Content; |
13
|
|
|
use eZ\Publish\API\Repository\Values\User\PasswordInfo; |
14
|
|
|
use eZ\Publish\API\Repository\Values\User\PasswordValidationContext; |
15
|
|
|
use eZ\Publish\API\Repository\Values\User\UserTokenUpdateStruct; |
16
|
|
|
use eZ\Publish\API\Repository\Values\User\UserGroupCreateStruct; |
17
|
|
|
use eZ\Publish\API\Repository\Values\User\UserGroupUpdateStruct; |
18
|
|
|
use eZ\Publish\API\Repository\Values\User\UserCreateStruct; |
19
|
|
|
use eZ\Publish\API\Repository\Values\User\UserGroup; |
20
|
|
|
use eZ\Publish\API\Repository\Values\User\User; |
21
|
|
|
use eZ\Publish\API\Repository\Values\User\UserUpdateStruct; |
22
|
|
|
use eZ\Publish\Core\SignalSlot\Signal\UserService\CreateUserGroupSignal; |
23
|
|
|
use eZ\Publish\Core\SignalSlot\Signal\UserService\DeleteUserGroupSignal; |
24
|
|
|
use eZ\Publish\Core\SignalSlot\Signal\UserService\MoveUserGroupSignal; |
25
|
|
|
use eZ\Publish\Core\SignalSlot\Signal\UserService\UpdateUserTokenSignal; |
26
|
|
|
use eZ\Publish\Core\SignalSlot\Signal\UserService\UpdateUserGroupSignal; |
27
|
|
|
use eZ\Publish\Core\SignalSlot\Signal\UserService\CreateUserSignal; |
28
|
|
|
use eZ\Publish\Core\SignalSlot\Signal\UserService\DeleteUserSignal; |
29
|
|
|
use eZ\Publish\Core\SignalSlot\Signal\UserService\UpdateUserSignal; |
30
|
|
|
use eZ\Publish\Core\SignalSlot\Signal\UserService\AssignUserToUserGroupSignal; |
31
|
|
|
use eZ\Publish\Core\SignalSlot\Signal\UserService\UnAssignUserFromUserGroupSignal; |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* UserService class. |
35
|
|
|
*/ |
36
|
|
|
class UserService implements UserServiceInterface |
37
|
|
|
{ |
38
|
|
|
/** |
39
|
|
|
* Aggregated service. |
40
|
|
|
* |
41
|
|
|
* @var \eZ\Publish\API\Repository\UserService |
42
|
|
|
*/ |
43
|
|
|
protected $service; |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* SignalDispatcher. |
47
|
|
|
* |
48
|
|
|
* @var \eZ\Publish\Core\SignalSlot\SignalDispatcher |
49
|
|
|
*/ |
50
|
|
|
protected $signalDispatcher; |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* Constructor. |
54
|
|
|
* |
55
|
|
|
* Construct service object from aggregated service and signal |
56
|
|
|
* dispatcher |
57
|
|
|
* |
58
|
|
|
* @param \eZ\Publish\API\Repository\UserService $service |
59
|
|
|
* @param \eZ\Publish\Core\SignalSlot\SignalDispatcher $signalDispatcher |
60
|
|
|
*/ |
61
|
|
|
public function __construct(UserServiceInterface $service, SignalDispatcher $signalDispatcher) |
62
|
|
|
{ |
63
|
|
|
$this->service = $service; |
64
|
|
|
$this->signalDispatcher = $signalDispatcher; |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* Creates a new user group using the data provided in the ContentCreateStruct parameter. |
69
|
|
|
* |
70
|
|
|
* In 4.x in the content type parameter in the profile is ignored |
71
|
|
|
* - the content type is determined via configuration and can be set to null. |
72
|
|
|
* The returned version is published. |
73
|
|
|
* |
74
|
|
|
* @param \eZ\Publish\API\Repository\Values\User\UserGroupCreateStruct $userGroupCreateStruct a structure for setting all necessary data to create this user group |
75
|
|
|
* @param \eZ\Publish\API\Repository\Values\User\UserGroup $parentGroup |
76
|
|
|
* |
77
|
|
|
* @return \eZ\Publish\API\Repository\Values\User\UserGroup |
78
|
|
|
* |
79
|
|
|
* @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the authenticated user is not allowed to create a user group |
80
|
|
|
* @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException if the input structure has invalid data |
81
|
|
|
* @throws \eZ\Publish\API\Repository\Exceptions\ContentFieldValidationException if a field in the $userGroupCreateStruct is not valid |
82
|
|
|
* @throws \eZ\Publish\API\Repository\Exceptions\ContentValidationException if a required field is missing or set to an empty value |
83
|
|
|
*/ |
84
|
|
|
public function createUserGroup(UserGroupCreateStruct $userGroupCreateStruct, UserGroup $parentGroup) |
85
|
|
|
{ |
86
|
|
|
$returnValue = $this->service->createUserGroup($userGroupCreateStruct, $parentGroup); |
87
|
|
|
$this->signalDispatcher->emit( |
88
|
|
|
new CreateUserGroupSignal( |
89
|
|
|
[ |
90
|
|
|
'userGroupId' => $returnValue->id, |
91
|
|
|
] |
92
|
|
|
) |
93
|
|
|
); |
94
|
|
|
|
95
|
|
|
return $returnValue; |
96
|
|
|
} |
97
|
|
|
|
98
|
|
|
/** |
99
|
|
|
* Loads a user group for the given id. |
100
|
|
|
* |
101
|
|
|
* @param mixed $id |
102
|
|
|
* @param string[] $prioritizedLanguages Used as prioritized language code on translated properties of returned object. |
103
|
|
|
* |
104
|
|
|
* @return \eZ\Publish\API\Repository\Values\User\UserGroup |
105
|
|
|
* |
106
|
|
|
* @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the authenticated user is not allowed to create a user group |
107
|
|
|
* @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException if the user group with the given id was not found |
108
|
|
|
*/ |
109
|
|
|
public function loadUserGroup($id, array $prioritizedLanguages = []) |
110
|
|
|
{ |
111
|
|
|
return $this->service->loadUserGroup($id, $prioritizedLanguages); |
112
|
|
|
} |
113
|
|
|
|
114
|
|
|
/** |
115
|
|
|
* Loads the sub groups of a user group. |
116
|
|
|
* |
117
|
|
|
* @param \eZ\Publish\API\Repository\Values\User\UserGroup $userGroup |
118
|
|
|
* @param int $offset the start offset for paging |
119
|
|
|
* @param int $limit the number of user groups returned |
120
|
|
|
* @param string[] $prioritizedLanguages Used as prioritized language code on translated properties of returned object. |
121
|
|
|
* |
122
|
|
|
* @return \eZ\Publish\API\Repository\Values\User\UserGroup[] |
123
|
|
|
* |
124
|
|
|
* @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the authenticated user is not allowed to read the user group |
125
|
|
|
*/ |
126
|
|
|
public function loadSubUserGroups(UserGroup $userGroup, $offset = 0, $limit = 25, array $prioritizedLanguages = []) |
127
|
|
|
{ |
128
|
|
|
return $this->service->loadSubUserGroups($userGroup, $offset, $limit, $prioritizedLanguages); |
129
|
|
|
} |
130
|
|
|
|
131
|
|
|
/** |
132
|
|
|
* Removes a user group. |
133
|
|
|
* |
134
|
|
|
* the users which are not assigned to other groups will be deleted. |
135
|
|
|
* |
136
|
|
|
* @param \eZ\Publish\API\Repository\Values\User\UserGroup $userGroup |
137
|
|
|
* |
138
|
|
|
* @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the authenticated user is not allowed to create a user group |
139
|
|
|
*/ |
140
|
|
View Code Duplication |
public function deleteUserGroup(UserGroup $userGroup) |
141
|
|
|
{ |
142
|
|
|
$returnValue = $this->service->deleteUserGroup($userGroup); |
143
|
|
|
$this->signalDispatcher->emit( |
144
|
|
|
new DeleteUserGroupSignal( |
145
|
|
|
[ |
146
|
|
|
'userGroupId' => $userGroup->id, |
147
|
|
|
'affectedLocationIds' => $returnValue, |
148
|
|
|
] |
149
|
|
|
) |
150
|
|
|
); |
151
|
|
|
|
152
|
|
|
return $returnValue; |
153
|
|
|
} |
154
|
|
|
|
155
|
|
|
/** |
156
|
|
|
* Moves the user group to another parent. |
157
|
|
|
* |
158
|
|
|
* @param \eZ\Publish\API\Repository\Values\User\UserGroup $userGroup |
159
|
|
|
* @param \eZ\Publish\API\Repository\Values\User\UserGroup $newParent |
160
|
|
|
* |
161
|
|
|
* @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the authenticated user is not allowed to move the user group |
162
|
|
|
*/ |
163
|
|
View Code Duplication |
public function moveUserGroup(UserGroup $userGroup, UserGroup $newParent) |
164
|
|
|
{ |
165
|
|
|
$returnValue = $this->service->moveUserGroup($userGroup, $newParent); |
166
|
|
|
$this->signalDispatcher->emit( |
167
|
|
|
new MoveUserGroupSignal( |
168
|
|
|
[ |
169
|
|
|
'userGroupId' => $userGroup->id, |
170
|
|
|
'newParentId' => $newParent->id, |
171
|
|
|
] |
172
|
|
|
) |
173
|
|
|
); |
174
|
|
|
|
175
|
|
|
return $returnValue; |
176
|
|
|
} |
177
|
|
|
|
178
|
|
|
/** |
179
|
|
|
* Updates the group profile with fields and meta data. |
180
|
|
|
* |
181
|
|
|
* 4.x: If the versionUpdateStruct is set in $userGroupUpdateStruct, this method internally creates a content draft, updates ts with the provided data |
182
|
|
|
* and publishes the draft. If a draft is explicitly required, the user group can be updated via the content service methods. |
183
|
|
|
* |
184
|
|
|
* @param \eZ\Publish\API\Repository\Values\User\UserGroup $userGroup |
185
|
|
|
* @param \eZ\Publish\API\Repository\Values\User\UserGroupUpdateStruct $userGroupUpdateStruct |
186
|
|
|
* |
187
|
|
|
* @return \eZ\Publish\API\Repository\Values\User\UserGroup |
188
|
|
|
* |
189
|
|
|
* @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the authenticated user is not allowed to move the user group |
190
|
|
|
* @throws \eZ\Publish\API\Repository\Exceptions\ContentFieldValidationException if a field in the $userGroupUpdateStruct is not valid |
191
|
|
|
* @throws \eZ\Publish\API\Repository\Exceptions\ContentValidationException if a required field is set empty |
192
|
|
|
* @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException if a field value is not accepted by the field type |
193
|
|
|
*/ |
194
|
|
|
public function updateUserGroup(UserGroup $userGroup, UserGroupUpdateStruct $userGroupUpdateStruct) |
195
|
|
|
{ |
196
|
|
|
$returnValue = $this->service->updateUserGroup($userGroup, $userGroupUpdateStruct); |
197
|
|
|
$this->signalDispatcher->emit( |
198
|
|
|
new UpdateUserGroupSignal( |
199
|
|
|
[ |
200
|
|
|
'userGroupId' => $userGroup->id, |
201
|
|
|
] |
202
|
|
|
) |
203
|
|
|
); |
204
|
|
|
|
205
|
|
|
return $returnValue; |
206
|
|
|
} |
207
|
|
|
|
208
|
|
|
/** |
209
|
|
|
* Create a new user. The created user is published by this method. |
210
|
|
|
* |
211
|
|
|
* @param \eZ\Publish\API\Repository\Values\User\UserCreateStruct $userCreateStruct the data used for creating the user |
212
|
|
|
* @param array $parentGroups the groups of type {@link \eZ\Publish\API\Repository\Values\User\UserGroup} which are assigned to the user after creation |
213
|
|
|
* |
214
|
|
|
* @return \eZ\Publish\API\Repository\Values\User\User |
215
|
|
|
* |
216
|
|
|
* @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the authenticated user is not allowed to move the user group |
217
|
|
|
* @throws \eZ\Publish\API\Repository\Exceptions\ContentFieldValidationException if a field in the $userCreateStruct is not valid |
218
|
|
|
* @throws \eZ\Publish\API\Repository\Exceptions\ContentValidationException if a required field is missing or set to an empty value |
219
|
|
|
* @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException if a field value is not accepted by the field type |
220
|
|
|
* if a user with provided login already exists |
221
|
|
|
*/ |
222
|
|
|
public function createUser(UserCreateStruct $userCreateStruct, array $parentGroups) |
223
|
|
|
{ |
224
|
|
|
$returnValue = $this->service->createUser($userCreateStruct, $parentGroups); |
225
|
|
|
$this->signalDispatcher->emit( |
226
|
|
|
new CreateUserSignal( |
227
|
|
|
[ |
228
|
|
|
'userId' => $returnValue->id, |
229
|
|
|
] |
230
|
|
|
) |
231
|
|
|
); |
232
|
|
|
|
233
|
|
|
return $returnValue; |
234
|
|
|
} |
235
|
|
|
|
236
|
|
|
/** |
237
|
|
|
* Loads a user. |
238
|
|
|
* |
239
|
|
|
* @param mixed $userId |
240
|
|
|
* @param string[] $prioritizedLanguages Used as prioritized language code on translated properties of returned object. |
241
|
|
|
* |
242
|
|
|
* @return \eZ\Publish\API\Repository\Values\User\User |
243
|
|
|
* |
244
|
|
|
* @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException if a user with the given id was not found |
245
|
|
|
*/ |
246
|
|
|
public function loadUser($userId, array $prioritizedLanguages = []) |
247
|
|
|
{ |
248
|
|
|
return $this->service->loadUser($userId, $prioritizedLanguages); |
249
|
|
|
} |
250
|
|
|
|
251
|
|
|
/** |
252
|
|
|
* Loads anonymous user. |
253
|
|
|
* |
254
|
|
|
* @deprecated since 5.3, use loadUser( $anonymousUserId ) instead |
255
|
|
|
* |
256
|
|
|
* @uses ::loadUser() |
257
|
|
|
* |
258
|
|
|
* @return \eZ\Publish\API\Repository\Values\User\User |
259
|
|
|
*/ |
260
|
|
|
public function loadAnonymousUser() |
261
|
|
|
{ |
262
|
|
|
return $this->service->loadAnonymousUser(); |
|
|
|
|
263
|
|
|
} |
264
|
|
|
|
265
|
|
|
/** |
266
|
|
|
* Loads a user for the given login and password. |
267
|
|
|
* |
268
|
|
|
* {@inheritdoc} |
269
|
|
|
* |
270
|
|
|
* @param string $login |
271
|
|
|
* @param string $password the plain password |
272
|
|
|
* @param string[] $prioritizedLanguages Used as prioritized language code on translated properties of returned object. |
273
|
|
|
* |
274
|
|
|
* @return \eZ\Publish\API\Repository\Values\User\User |
275
|
|
|
* |
276
|
|
|
* @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException if credentials are invalid |
277
|
|
|
* @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException if a user with the given credentials was not found |
278
|
|
|
*/ |
279
|
|
|
public function loadUserByCredentials($login, $password, array $prioritizedLanguages = []) |
280
|
|
|
{ |
281
|
|
|
return $this->service->loadUserByCredentials($login, $password, $prioritizedLanguages); |
|
|
|
|
282
|
|
|
} |
283
|
|
|
|
284
|
|
|
/** |
285
|
|
|
* Checks if credentials are valid for provided User. |
286
|
|
|
* |
287
|
|
|
* @param \eZ\Publish\API\Repository\Values\User\User $user |
288
|
|
|
* @param string $credentials |
289
|
|
|
* |
290
|
|
|
* @return bool |
291
|
|
|
*/ |
292
|
|
|
public function checkUserCredentials(User $user, string $credentials): bool |
293
|
|
|
{ |
294
|
|
|
return $this->service->checkUserCredentials($user, $credentials); |
295
|
|
|
} |
296
|
|
|
|
297
|
|
|
/** |
298
|
|
|
* Loads a user for the given login. |
299
|
|
|
* |
300
|
|
|
* {@inheritdoc} |
301
|
|
|
* |
302
|
|
|
* @param string $login |
303
|
|
|
* @param string[] $prioritizedLanguages Used as prioritized language code on translated properties of returned object. |
304
|
|
|
* |
305
|
|
|
* @return \eZ\Publish\API\Repository\Values\User\User |
306
|
|
|
* |
307
|
|
|
* @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException if a user with the given credentials was not found |
308
|
|
|
*/ |
309
|
|
|
public function loadUserByLogin($login, array $prioritizedLanguages = []) |
310
|
|
|
{ |
311
|
|
|
return $this->service->loadUserByLogin($login, $prioritizedLanguages); |
312
|
|
|
} |
313
|
|
|
|
314
|
|
|
/** |
315
|
|
|
* Loads a user for the given email. |
316
|
|
|
* |
317
|
|
|
* {@inheritdoc} |
318
|
|
|
* |
319
|
|
|
* @param string $email |
320
|
|
|
* @param string[] $prioritizedLanguages Used as prioritized language code on translated properties of returned object. |
321
|
|
|
* |
322
|
|
|
* @return \eZ\Publish\API\Repository\Values\User\User[] |
323
|
|
|
*/ |
324
|
|
|
public function loadUsersByEmail($email, array $prioritizedLanguages = []) |
325
|
|
|
{ |
326
|
|
|
return $this->service->loadUsersByEmail($email, $prioritizedLanguages); |
327
|
|
|
} |
328
|
|
|
|
329
|
|
|
/** |
330
|
|
|
* Loads a user with user hash key. |
331
|
|
|
* |
332
|
|
|
* {@inheritdoc} |
333
|
|
|
* |
334
|
|
|
* @param string $hash |
335
|
|
|
* @param string[] $prioritizedLanguages Used as prioritized language code on translated properties of returned object. |
336
|
|
|
* |
337
|
|
|
* @return \eZ\Publish\API\Repository\Values\User\User |
338
|
|
|
* |
339
|
|
|
* @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException if a user with the given hash was not found |
340
|
|
|
*/ |
341
|
|
|
public function loadUserByToken($hash, array $prioritizedLanguages = []) |
342
|
|
|
{ |
343
|
|
|
return $this->service->loadUserByToken($hash, $prioritizedLanguages); |
344
|
|
|
} |
345
|
|
|
|
346
|
|
|
/** |
347
|
|
|
* This method deletes a user. |
348
|
|
|
* |
349
|
|
|
* @param \eZ\Publish\API\Repository\Values\User\User $user |
350
|
|
|
* |
351
|
|
|
* @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the authenticated user is not allowed to delete the user |
352
|
|
|
*/ |
353
|
|
|
public function deleteUser(User $user) |
354
|
|
|
{ |
355
|
|
|
$returnValue = $this->service->deleteUser($user); |
356
|
|
|
$this->signalDispatcher->emit( |
357
|
|
|
new DeleteUserSignal( |
358
|
|
|
[ |
359
|
|
|
'userId' => $user->id, |
360
|
|
|
'affectedLocationIds' => $returnValue, |
361
|
|
|
] |
362
|
|
|
) |
363
|
|
|
); |
364
|
|
|
|
365
|
|
|
return $returnValue; |
366
|
|
|
} |
367
|
|
|
|
368
|
|
|
/** |
369
|
|
|
* Updates a user. |
370
|
|
|
* |
371
|
|
|
* 4.x: If the versionUpdateStruct is set in the user update structure, this method internally creates a content draft, updates ts with the provided data |
372
|
|
|
* and publishes the draft. If a draft is explicitly required, the user group can be updated via the content service methods. |
373
|
|
|
* |
374
|
|
|
* @param \eZ\Publish\API\Repository\Values\User\User $user |
375
|
|
|
* @param \eZ\Publish\API\Repository\Values\User\UserUpdateStruct $userUpdateStruct |
376
|
|
|
* |
377
|
|
|
* @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the authenticated user is not allowed to update the user |
378
|
|
|
* @throws \eZ\Publish\API\Repository\Exceptions\ContentFieldValidationException if a field in the $userUpdateStruct is not valid |
379
|
|
|
* @throws \eZ\Publish\API\Repository\Exceptions\ContentValidationException if a required field is set empty |
380
|
|
|
* @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException if a field value is not accepted by the field type |
381
|
|
|
* |
382
|
|
|
* @return \eZ\Publish\API\Repository\Values\User\User |
383
|
|
|
*/ |
384
|
|
|
public function updateUser(User $user, UserUpdateStruct $userUpdateStruct) |
385
|
|
|
{ |
386
|
|
|
$returnValue = $this->service->updateUser($user, $userUpdateStruct); |
387
|
|
|
$this->signalDispatcher->emit( |
388
|
|
|
new UpdateUserSignal( |
389
|
|
|
[ |
390
|
|
|
'userId' => $user->id, |
391
|
|
|
] |
392
|
|
|
) |
393
|
|
|
); |
394
|
|
|
|
395
|
|
|
return $returnValue; |
396
|
|
|
} |
397
|
|
|
|
398
|
|
|
/** |
399
|
|
|
* Update the user account key information specified by the user account key struct. |
400
|
|
|
* |
401
|
|
|
* @param \eZ\Publish\API\Repository\Values\User\User $user |
402
|
|
|
* @param \eZ\Publish\API\Repository\Values\User\UserTokenUpdateStruct $userTokenUpdateStruct |
403
|
|
|
* |
404
|
|
|
* @return \eZ\Publish\API\Repository\Values\User\User |
405
|
|
|
*/ |
406
|
|
|
public function updateUserToken(User $user, UserTokenUpdateStruct $userTokenUpdateStruct) |
407
|
|
|
{ |
408
|
|
|
$returnValue = $this->service->updateUserToken($user, $userTokenUpdateStruct); |
409
|
|
|
$this->signalDispatcher->emit( |
410
|
|
|
new UpdateUserTokenSignal( |
411
|
|
|
['userId' => $user->id] |
412
|
|
|
) |
413
|
|
|
); |
414
|
|
|
|
415
|
|
|
return $returnValue; |
416
|
|
|
} |
417
|
|
|
|
418
|
|
|
/** |
419
|
|
|
* Expires user token with user hash. |
420
|
|
|
* |
421
|
|
|
* @param string $hash |
422
|
|
|
*/ |
423
|
|
|
public function expireUserToken($hash) |
424
|
|
|
{ |
425
|
|
|
return $this->service->expireUserToken($hash); |
426
|
|
|
} |
427
|
|
|
|
428
|
|
|
/** |
429
|
|
|
* Assigns a new user group to the user. |
430
|
|
|
* |
431
|
|
|
* @param \eZ\Publish\API\Repository\Values\User\User $user |
432
|
|
|
* @param \eZ\Publish\API\Repository\Values\User\UserGroup $userGroup |
433
|
|
|
* |
434
|
|
|
* @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the authenticated user is not allowed to assign the user group to the user |
435
|
|
|
* @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException if the user is already in the given user group |
436
|
|
|
*/ |
437
|
|
View Code Duplication |
public function assignUserToUserGroup(User $user, UserGroup $userGroup) |
438
|
|
|
{ |
439
|
|
|
$returnValue = $this->service->assignUserToUserGroup($user, $userGroup); |
440
|
|
|
$this->signalDispatcher->emit( |
441
|
|
|
new AssignUserToUserGroupSignal( |
442
|
|
|
[ |
443
|
|
|
'userId' => $user->id, |
444
|
|
|
'userGroupId' => $userGroup->id, |
445
|
|
|
] |
446
|
|
|
) |
447
|
|
|
); |
448
|
|
|
|
449
|
|
|
return $returnValue; |
450
|
|
|
} |
451
|
|
|
|
452
|
|
|
/** |
453
|
|
|
* Removes a user group from the user. |
454
|
|
|
* |
455
|
|
|
* @param \eZ\Publish\API\Repository\Values\User\User $user |
456
|
|
|
* @param \eZ\Publish\API\Repository\Values\User\UserGroup $userGroup |
457
|
|
|
* |
458
|
|
|
* @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the authenticated user is not allowed to remove the user group from the user |
459
|
|
|
* @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException if the user is not in the given user group |
460
|
|
|
*/ |
461
|
|
View Code Duplication |
public function unAssignUserFromUserGroup(User $user, UserGroup $userGroup) |
462
|
|
|
{ |
463
|
|
|
$returnValue = $this->service->unAssignUserFromUserGroup($user, $userGroup); |
464
|
|
|
$this->signalDispatcher->emit( |
465
|
|
|
new UnAssignUserFromUserGroupSignal( |
466
|
|
|
[ |
467
|
|
|
'userId' => $user->id, |
468
|
|
|
'userGroupId' => $userGroup->id, |
469
|
|
|
] |
470
|
|
|
) |
471
|
|
|
); |
472
|
|
|
|
473
|
|
|
return $returnValue; |
474
|
|
|
} |
475
|
|
|
|
476
|
|
|
/** |
477
|
|
|
* Loads the user groups the user belongs to. |
478
|
|
|
* |
479
|
|
|
* @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the authenticated user is not allowed read the user or user group |
480
|
|
|
* |
481
|
|
|
* @param \eZ\Publish\API\Repository\Values\User\User $user |
482
|
|
|
* @param int $offset the start offset for paging |
483
|
|
|
* @param int $limit the number of user groups returned |
484
|
|
|
* @param string[] $prioritizedLanguages Used as prioritized language code on translated properties of returned object. |
485
|
|
|
* |
486
|
|
|
* @return \eZ\Publish\API\Repository\Values\User\UserGroup[] |
487
|
|
|
*/ |
488
|
|
|
public function loadUserGroupsOfUser(User $user, $offset = 0, $limit = 25, array $prioritizedLanguages = []) |
489
|
|
|
{ |
490
|
|
|
return $this->service->loadUserGroupsOfUser($user, $offset, $limit, $prioritizedLanguages); |
491
|
|
|
} |
492
|
|
|
|
493
|
|
|
/** |
494
|
|
|
* Loads the users of a user group. |
495
|
|
|
* |
496
|
|
|
* @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the authenticated user is not allowed to read the users or user group |
497
|
|
|
* |
498
|
|
|
* @param \eZ\Publish\API\Repository\Values\User\UserGroup $userGroup |
499
|
|
|
* @param int $offset the start offset for paging |
500
|
|
|
* @param int $limit the number of users returned |
501
|
|
|
* @param string[] $prioritizedLanguages Used as prioritized language code on translated properties of returned object. |
502
|
|
|
* |
503
|
|
|
* @return \eZ\Publish\API\Repository\Values\User\User[] |
504
|
|
|
*/ |
505
|
|
|
public function loadUsersOfUserGroup( |
506
|
|
|
UserGroup $userGroup, |
507
|
|
|
$offset = 0, |
508
|
|
|
$limit = 25, |
509
|
|
|
array $prioritizedLanguages = [] |
510
|
|
|
) { |
511
|
|
|
return $this->service->loadUsersOfUserGroup( |
512
|
|
|
$userGroup, |
513
|
|
|
$offset, |
514
|
|
|
$limit, |
515
|
|
|
$prioritizedLanguages |
516
|
|
|
); |
517
|
|
|
} |
518
|
|
|
|
519
|
|
|
/** |
520
|
|
|
* {@inheritdoc} |
521
|
|
|
*/ |
522
|
|
|
public function isUser(Content $content): bool |
523
|
|
|
{ |
524
|
|
|
return $this->service->isUser($content); |
525
|
|
|
} |
526
|
|
|
|
527
|
|
|
/** |
528
|
|
|
* {@inheritdoc} |
529
|
|
|
*/ |
530
|
|
|
public function isUserGroup(Content $content): bool |
531
|
|
|
{ |
532
|
|
|
return $this->service->isUserGroup($content); |
533
|
|
|
} |
534
|
|
|
|
535
|
|
|
/** |
536
|
|
|
* Instantiate a user create class. |
537
|
|
|
* |
538
|
|
|
* @param string $login the login of the new user |
539
|
|
|
* @param string $email the email of the new user |
540
|
|
|
* @param string $password the plain password of the new user |
541
|
|
|
* @param string $mainLanguageCode the main language for the underlying content object |
542
|
|
|
* @param \eZ\Publish\API\Repository\Values\ContentType\ContentType $contentType 5.x the content type for the underlying content object. In 4.x it is ignored and taken from the configuration |
543
|
|
|
* |
544
|
|
|
* @return \eZ\Publish\API\Repository\Values\User\UserCreateStruct |
545
|
|
|
*/ |
546
|
|
|
public function newUserCreateStruct($login, $email, $password, $mainLanguageCode, $contentType = null) |
547
|
|
|
{ |
548
|
|
|
return $this->service->newUserCreateStruct($login, $email, $password, $mainLanguageCode, $contentType); |
549
|
|
|
} |
550
|
|
|
|
551
|
|
|
/** |
552
|
|
|
* Instantiate a user group create class. |
553
|
|
|
* |
554
|
|
|
* @param string $mainLanguageCode The main language for the underlying content object |
555
|
|
|
* @param null|\eZ\Publish\API\Repository\Values\ContentType\ContentType $contentType 5.x the content type for the underlying content object. In 4.x it is ignored and taken from the configuration |
556
|
|
|
* |
557
|
|
|
* @return \eZ\Publish\API\Repository\Values\User\UserGroupCreateStruct |
558
|
|
|
*/ |
559
|
|
|
public function newUserGroupCreateStruct($mainLanguageCode, $contentType = null) |
560
|
|
|
{ |
561
|
|
|
return $this->service->newUserGroupCreateStruct($mainLanguageCode, $contentType); |
562
|
|
|
} |
563
|
|
|
|
564
|
|
|
/** |
565
|
|
|
* Instantiate a new user update struct. |
566
|
|
|
* |
567
|
|
|
* @return \eZ\Publish\API\Repository\Values\User\UserUpdateStruct |
568
|
|
|
*/ |
569
|
|
|
public function newUserUpdateStruct() |
570
|
|
|
{ |
571
|
|
|
return $this->service->newUserUpdateStruct(); |
572
|
|
|
} |
573
|
|
|
|
574
|
|
|
/** |
575
|
|
|
* Instantiate a new user group update struct. |
576
|
|
|
* |
577
|
|
|
* @return \eZ\Publish\API\Repository\Values\User\UserGroupUpdateStruct |
578
|
|
|
*/ |
579
|
|
|
public function newUserGroupUpdateStruct() |
580
|
|
|
{ |
581
|
|
|
return $this->service->newUserGroupUpdateStruct(); |
582
|
|
|
} |
583
|
|
|
|
584
|
|
|
/** |
585
|
|
|
* {@inheritdoc} |
586
|
|
|
*/ |
587
|
|
|
public function validatePassword(string $password, PasswordValidationContext $context = null): array |
588
|
|
|
{ |
589
|
|
|
return $this->service->validatePassword($password, $context); |
590
|
|
|
} |
591
|
|
|
|
592
|
|
|
public function getPasswordInfo(User $user): PasswordInfo |
593
|
|
|
{ |
594
|
|
|
return $this->service->getPasswordInfo($user); |
595
|
|
|
} |
596
|
|
|
} |
597
|
|
|
|
This method has been deprecated. The supplier of the class has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.