Completed
Push — master ( 8107b6...19db21 )
by
unknown
20:08
created

UserService::loadUserByToken()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 2
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * File containing the 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\REST\Client;
10
11
use eZ\Publish\API\Repository\UserService as APIUserService;
12
use eZ\Publish\API\Repository\Values\User\User;
13
use eZ\Publish\API\Repository\Values\User\UserCreateStruct;
14
use eZ\Publish\API\Repository\Values\User\UserTokenUpdateStruct;
15
use eZ\Publish\API\Repository\Values\User\UserUpdateStruct;
16
use eZ\Publish\API\Repository\Values\User\UserGroup;
17
use eZ\Publish\API\Repository\Values\User\UserGroupCreateStruct;
18
use eZ\Publish\API\Repository\Values\User\UserGroupUpdateStruct;
19
use eZ\Publish\Core\REST\Common\RequestParser;
20
use eZ\Publish\Core\REST\Common\Input\Dispatcher;
21
use eZ\Publish\Core\REST\Common\Output\Visitor;
22
23
/**
24
 * Implementation of the {@link \eZ\Publish\API\Repository\UserService}
25
 * interface.
26
 *
27
 * @see \eZ\Publish\API\Repository\UserService
28
 */
29
class UserService implements APIUserService, Sessionable
30
{
31
    /**
32
     * @var \eZ\Publish\Core\REST\Client\HttpClient
33
     */
34
    private $client;
35
36
    /**
37
     * @var \eZ\Publish\Core\REST\Common\Input\Dispatcher
38
     */
39
    private $inputDispatcher;
40
41
    /**
42
     * @var \eZ\Publish\Core\REST\Common\Output\Visitor
43
     */
44
    private $outputVisitor;
45
46
    /**
47
     * @var \eZ\Publish\Core\REST\Common\RequestParser
48
     */
49
    private $requestParser;
50
51
    /**
52
     * @param \eZ\Publish\Core\REST\Client\HttpClient $client
53
     * @param \eZ\Publish\Core\REST\Common\Input\Dispatcher $inputDispatcher
54
     * @param \eZ\Publish\Core\REST\Common\Output\Visitor $outputVisitor
55
     * @param \eZ\Publish\Core\REST\Common\RequestParser $requestParser
56
     */
57 View Code Duplication
    public function __construct(HttpClient $client, Dispatcher $inputDispatcher, Visitor $outputVisitor, RequestParser $requestParser)
58
    {
59
        $this->client = $client;
60
        $this->inputDispatcher = $inputDispatcher;
61
        $this->outputVisitor = $outputVisitor;
62
        $this->requestParser = $requestParser;
63
    }
64
65
    /**
66
     * Set session ID.
67
     *
68
     * Only for testing
69
     *
70
     * @param mixed tringid
71
     *
72
     * @private
73
     */
74
    public function setSession($id)
75
    {
76
        if ($this->outputVisitor instanceof Sessionable) {
77
            $this->outputVisitor->setSession($id);
78
        }
79
    }
80
81
    /**
82
     * Creates a new user group using the data provided in the ContentCreateStruct parameter.
83
     *
84
     * In 4.x in the content type parameter in the profile is ignored
85
     * - the content type is determined via configuration and can be set to null.
86
     * The returned version is published.
87
     *
88
     * @param \eZ\Publish\API\Repository\Values\User\UserGroupCreateStruct $userGroupCreateStruct a structure for setting all necessary data to create this user group
89
     * @param \eZ\Publish\API\Repository\Values\User\UserGroup $parentGroup
90
     *
91
     * @return \eZ\Publish\API\Repository\Values\User\UserGroup
92
     *
93
     * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the authenticated user is not allowed to create a user group
94
     * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException if the input structure has invalid data
95
     * @throws \eZ\Publish\API\Repository\Exceptions\ContentFieldValidationException if a field in the $userGroupCreateStruct is not valid
96
     * @throws \eZ\Publish\API\Repository\Exceptions\ContentValidationException if a required field is missing
97
     */
98
    public function createUserGroup(UserGroupCreateStruct $userGroupCreateStruct, UserGroup $parentGroup)
99
    {
100
        throw new \Exception('@todo: Implement.');
101
    }
102
103
    /**
104
     * {@inheritdoc}
105
     */
106
    public function loadUserGroup($id, array $prioritizedLanguages = [])
107
    {
108
        throw new \Exception('@todo: Implement.');
109
    }
110
111
    /**
112
     * {@inheritdoc}
113
     */
114
    public function loadSubUserGroups(UserGroup $userGroup, $offset = 0, $limit = 25, array $prioritizedLanguages = [])
115
    {
116
        throw new \Exception('@todo: Implement.');
117
    }
118
119
    /**
120
     * Removes a user group.
121
     *
122
     * the users which are not assigned to other groups will be deleted.
123
     *
124
     * @param \eZ\Publish\API\Repository\Values\User\UserGroup $userGroup
125
     *
126
     * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the authenticated user is not allowed to create a user group
127
     */
128
    public function deleteUserGroup(UserGroup $userGroup)
129
    {
130
        throw new \Exception('@todo: Implement.');
131
    }
132
133
    /**
134
     * Moves the user group to another parent.
135
     *
136
     * @param \eZ\Publish\API\Repository\Values\User\UserGroup $userGroup
137
     * @param \eZ\Publish\API\Repository\Values\User\UserGroup $newParent
138
     *
139
     * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the authenticated user is not allowed to move the user group
140
     */
141
    public function moveUserGroup(UserGroup $userGroup, UserGroup $newParent)
142
    {
143
        throw new \Exception('@todo: Implement.');
144
    }
145
146
    /**
147
     * Updates the group profile with fields and meta data.
148
     *
149
     * 4.x: If the versionUpdateStruct is set in $userGroupUpdateStruct, this method internally creates a content draft, updates ts with the provided data
150
     * and publishes the draft. If a draft is explicitly required, the user group can be updated via the content service methods.
151
     *
152
     * @param \eZ\Publish\API\Repository\Values\User\UserGroup $userGroup
153
     * @param \eZ\Publish\API\Repository\Values\User\UserGroupUpdateStruct $userGroupUpdateStruct
154
     *
155
     * @return \eZ\Publish\API\Repository\Values\User\UserGroup
156
     *
157
     * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the authenticated user is not allowed to move the user group
158
     * @throws \eZ\Publish\API\Repository\Exceptions\ContentFieldValidationException if a field in the $userGroupUpdateStruct is not valid
159
     * @throws \eZ\Publish\API\Repository\Exceptions\ContentValidationException if a required field is set empty
160
     */
161
    public function updateUserGroup(UserGroup $userGroup, UserGroupUpdateStruct $userGroupUpdateStruct)
162
    {
163
        throw new \Exception('@todo: Implement.');
164
    }
165
166
    /**
167
     * Create a new user. The created user is published by this method.
168
     *
169
     * @param \eZ\Publish\API\Repository\Values\User\UserCreateStruct $userCreateStruct the data used for creating the user
170
     * @param array $parentGroups the groups of type {@link \eZ\Publish\API\Repository\Values\User\UserGroup} which are assigned to the user after creation
171
     *
172
     * @return \eZ\Publish\API\Repository\Values\User\User
173
     *
174
     * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the authenticated user is not allowed to move the user group
175
     * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException if a user group was not found
176
     * @throws \eZ\Publish\API\Repository\Exceptions\ContentFieldValidationException if a field in the $userCreateStruct is not valid
177
     * @throws \eZ\Publish\API\Repository\Exceptions\ContentValidationException if a required field is missing
178
     * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException if a user with provided login already exists
179
     */
180
    public function createUser(UserCreateStruct $userCreateStruct, array $parentGroups)
181
    {
182
        throw new \Exception('@todo: Implement.');
183
    }
184
185
    /**
186
     * {@inheritdoc}
187
     */
188
    public function loadUser($userId, array $prioritizedLanguages = [])
189
    {
190
        throw new \Exception('@todo: Implement.');
191
    }
192
193
    /**
194
     * Loads anonymous user.
195
     *
196
     * @deprecated since 5.3, use loadUser( $anonymousUserId ) instead
197
     *
198
     *
199
     * @return \eZ\Publish\API\Repository\Values\User\User
200
     */
201
    public function loadAnonymousUser()
202
    {
203
        throw new \Exception('@todo: Implement.');
204
    }
205
206
    /**
207
     * {@inheritdoc}
208
     */
209
    public function loadUserByCredentials($login, $password, array $prioritizedLanguages = [])
210
    {
211
        throw new \Exception('@todo: Implement.');
212
    }
213
214
    /**
215
     * {@inheritdoc}
216
     */
217
    public function loadUserByLogin($login, array $prioritizedLanguages = [])
218
    {
219
        throw new \Exception('@todo: Implement.');
220
    }
221
222
    /**
223
     * {@inheritdoc}
224
     */
225
    public function loadUsersByEmail($email, array $prioritizedLanguages = [])
226
    {
227
        throw new \Exception('@todo: Implement.');
228
    }
229
230
    /**
231
     * Loads a user with user hash key.
232
     *
233
     * @param string $hash
234
     * @param array $prioritizedLanguages
235
     *
236
     * @return \eZ\Publish\API\Repository\Values\User\User
237
     */
238
    public function loadUserByToken($hash, array $prioritizedLanguages = [])
239
    {
240
        throw new \Exception('@todo: Implement.');
241
    }
242
243
    /**
244
     * This method deletes a user.
245
     *
246
     * @param \eZ\Publish\API\Repository\Values\User\User $user
247
     *
248
     * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the authenticated user is not allowed to delete the user
249
     */
250
    public function deleteUser(User $user)
251
    {
252
        throw new \Exception('@todo: Implement.');
253
    }
254
255
    /**
256
     * Updates a user.
257
     *
258
     * 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
259
     * and publishes the draft. If a draft is explicitly required, the user group can be updated via the content service methods.
260
     *
261
     * @param \eZ\Publish\API\Repository\Values\User\User $user
262
     * @param \eZ\Publish\API\Repository\Values\User\UserUpdateStruct $userUpdateStruct
263
     *
264
     * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the authenticated user is not allowed to update the user
265
     * @throws \eZ\Publish\API\Repository\Exceptions\ContentFieldValidationException if a field in the $userUpdateStruct is not valid
266
     * @throws \eZ\Publish\API\Repository\Exceptions\ContentValidationException if a required field is set empty
267
     *
268
     * @return \eZ\Publish\API\Repository\Values\User\User
269
     */
270
    public function updateUser(User $user, UserUpdateStruct $userUpdateStruct)
271
    {
272
        throw new \Exception('@todo: Implement.');
273
    }
274
275
    /**
276
     * Update the user token information specified by the user token struct.
277
     *
278
     * @param \eZ\Publish\API\Repository\Values\User\User $user
279
     * @param \eZ\Publish\API\Repository\Values\User\UserTokenUpdateStruct $userTokenUpdateStruct
280
     *
281
     * @return \eZ\Publish\API\Repository\Values\User\User
282
     */
283
    public function updateUserToken(User $user, UserTokenUpdateStruct $userTokenUpdateStruct)
284
    {
285
        throw new \Exception('@todo: Implement.');
286
    }
287
288
    /**
289
     * Expires user token with user hash.
290
     *
291
     * @param string $hash
292
     */
293
    public function expireUserToken($hash)
294
    {
295
        throw new \Exception('@todo: Implement.');
296
    }
297
298
299
    /**
300
     * Assigns a new user group to the user.
301
     *
302
     * @param \eZ\Publish\API\Repository\Values\User\User $user
303
     * @param \eZ\Publish\API\Repository\Values\User\UserGroup $userGroup
304
     *
305
     * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the authenticated user is not allowed to assign the user group to the user
306
     * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException if the user is already in the given user group
307
     */
308
    public function assignUserToUserGroup(User $user, UserGroup $userGroup)
309
    {
310
        throw new \Exception('@todo: Implement.');
311
    }
312
313
    /**
314
     * Removes a user group from the user.
315
     *
316
     * @param \eZ\Publish\API\Repository\Values\User\User $user
317
     * @param \eZ\Publish\API\Repository\Values\User\UserGroup $userGroup
318
     *
319
     * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the authenticated user is not allowed to remove the user group from the user
320
     * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException if the user is not in the given user group
321
     */
322
    public function unAssignUserFromUserGroup(User $user, UserGroup $userGroup)
323
    {
324
        throw new \Exception('@todo: Implement.');
325
    }
326
327
    /**
328
     * {@inheritdoc}
329
     */
330
    public function loadUserGroupsOfUser(User $user, $offset = 0, $limit = 25, array $prioritizedLanguages = [])
331
    {
332
        throw new \Exception('@todo: Implement.');
333
    }
334
335
    /**
336
     * {@inheritdoc}
337
     */
338
    public function loadUsersOfUserGroup(
339
        UserGroup $userGroup,
340
        $offset = 0,
341
        $limit = 25,
342
        array $prioritizedLanguages = []
343
    ) {
344
        throw new \Exception('@todo: Implement.');
345
    }
346
347
    /**
348
     * Instantiate a user create class.
349
     *
350
     * @param string $login the login of the new user
351
     * @param string $email the email of the new user
352
     * @param string $password the plain password of the new user
353
     * @param string $mainLanguageCode the main language for the underlying content object
354
     * @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
355
     *
356
     * @return \eZ\Publish\API\Repository\Values\User\UserCreateStruct
357
     */
358
    public function newUserCreateStruct($login, $email, $password, $mainLanguageCode, $contentType = null)
359
    {
360
        throw new \Exception('@todo: Implement.');
361
    }
362
363
    /**
364
     * Instantiate a user group create class.
365
     *
366
     * @param string $mainLanguageCode The main language for the underlying content object
367
     * @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
368
     *
369
     * @return \eZ\Publish\API\Repository\Values\User\UserGroupCreateStruct
370
     */
371
    public function newUserGroupCreateStruct($mainLanguageCode, $contentType = null)
372
    {
373
        throw new \Exception('@todo: Implement.');
374
    }
375
376
    /**
377
     * Instantiate a new user update struct.
378
     *
379
     * @return \eZ\Publish\API\Repository\Values\User\UserUpdateStruct
380
     */
381
    public function newUserUpdateStruct()
382
    {
383
        throw new \Exception('@todo: Implement.');
384
    }
385
386
    /**
387
     * Instantiate a new user group update struct.
388
     *
389
     * @return \eZ\Publish\API\Repository\Values\User\UserGroupUpdateStruct
390
     */
391
    public function newUserGroupUpdateStruct()
392
    {
393
        throw new \Exception('@todo: Implement.');
394
    }
395
}
396