1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* File containing the RoleService 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\RoleService as APIRoleService; |
12
|
|
|
use eZ\Publish\API\Repository\Values\User\Limitation\RoleLimitation; |
13
|
|
|
use eZ\Publish\API\Repository\Values\User\Policy as APIPolicy; |
14
|
|
|
use eZ\Publish\API\Repository\Values\User\PolicyCreateStruct as APIPolicyCreateStruct; |
15
|
|
|
use eZ\Publish\API\Repository\Values\User\PolicyDraft; |
16
|
|
|
use eZ\Publish\API\Repository\Values\User\PolicyUpdateStruct as APIPolicyUpdateStruct; |
17
|
|
|
use eZ\Publish\API\Repository\Values\User\Role as APIRole; |
18
|
|
|
use eZ\Publish\API\Repository\Values\User\RoleAssignment as APIRoleAssignment; |
19
|
|
|
use eZ\Publish\API\Repository\Values\User\RoleDraft as APIRoleDraft; |
20
|
|
|
use eZ\Publish\API\Repository\Values\User\RoleCreateStruct as APIRoleCreateStruct; |
21
|
|
|
use eZ\Publish\API\Repository\Values\User\RoleUpdateStruct; |
22
|
|
|
use eZ\Publish\API\Repository\Values\User\User; |
23
|
|
|
use eZ\Publish\API\Repository\Values\User\UserGroup; |
24
|
|
|
use eZ\Publish\Core\Repository\Values\User\RoleDraft; |
25
|
|
|
use eZ\Publish\Core\Repository\Values\User\UserRoleAssignment; |
26
|
|
|
use eZ\Publish\Core\Repository\Values\User\UserGroupRoleAssignment; |
27
|
|
|
use eZ\Publish\Core\REST\Client\Values\User\PolicyCreateStruct; |
28
|
|
|
use eZ\Publish\Core\REST\Client\Values\User\PolicyUpdateStruct; |
29
|
|
|
use eZ\Publish\Core\REST\Client\Values\User\Role; |
30
|
|
|
use eZ\Publish\Core\REST\Client\Values\User\Policy; |
31
|
|
|
use eZ\Publish\Core\REST\Client\Values\User\RoleAssignment; |
32
|
|
|
use eZ\Publish\Core\REST\Common\RequestParser; |
33
|
|
|
use eZ\Publish\Core\REST\Common\Input\Dispatcher; |
34
|
|
|
use eZ\Publish\Core\REST\Common\Output\Visitor; |
35
|
|
|
use eZ\Publish\Core\REST\Common\Message; |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* Implementation of the {@link \eZ\Publish\API\Repository\RoleService} |
39
|
|
|
* interface. |
40
|
|
|
* |
41
|
|
|
* @see \eZ\Publish\API\Repository\RoleService |
42
|
|
|
*/ |
43
|
|
|
class RoleService implements APIRoleService, Sessionable |
44
|
|
|
{ |
45
|
|
|
/** |
46
|
|
|
* @var \eZ\Publish\Core\REST\Client\UserService |
47
|
|
|
*/ |
48
|
|
|
private $userService; |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* @var \eZ\Publish\Core\REST\Client\HttpClient |
52
|
|
|
*/ |
53
|
|
|
private $client; |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* @var \eZ\Publish\Core\REST\Common\Input\Dispatcher |
57
|
|
|
*/ |
58
|
|
|
private $inputDispatcher; |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* @var \eZ\Publish\Core\REST\Common\Output\Visitor |
62
|
|
|
*/ |
63
|
|
|
private $outputVisitor; |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* @var \eZ\Publish\Core\REST\Common\RequestParser |
67
|
|
|
*/ |
68
|
|
|
private $requestParser; |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* @param \eZ\Publish\Core\REST\Client\UserService $userService |
72
|
|
|
* @param \eZ\Publish\Core\REST\Client\HttpClient $client |
73
|
|
|
* @param \eZ\Publish\Core\REST\Common\Input\Dispatcher $inputDispatcher |
74
|
|
|
* @param \eZ\Publish\Core\REST\Common\Output\Visitor $outputVisitor |
75
|
|
|
* @param \eZ\Publish\Core\REST\Common\RequestParser $requestParser |
76
|
|
|
*/ |
77
|
|
View Code Duplication |
public function __construct(UserService $userService, HttpClient $client, Dispatcher $inputDispatcher, Visitor $outputVisitor, RequestParser $requestParser) |
78
|
|
|
{ |
79
|
|
|
$this->userService = $userService; |
80
|
|
|
$this->client = $client; |
81
|
|
|
$this->inputDispatcher = $inputDispatcher; |
82
|
|
|
$this->outputVisitor = $outputVisitor; |
83
|
|
|
$this->requestParser = $requestParser; |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* Set session ID. |
88
|
|
|
* |
89
|
|
|
* Only for testing |
90
|
|
|
* |
91
|
|
|
* @param mixed $id |
92
|
|
|
* |
93
|
|
|
* @private |
94
|
|
|
*/ |
95
|
|
|
public function setSession($id) |
96
|
|
|
{ |
97
|
|
|
if ($this->outputVisitor instanceof Sessionable) { |
98
|
|
|
$this->outputVisitor->setSession($id); |
99
|
|
|
} |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
/** |
103
|
|
|
* Creates a new RoleDraft for existing Role. |
104
|
|
|
* |
105
|
|
|
* @since 6.0 |
106
|
|
|
* |
107
|
|
|
* @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the authenticated user is not allowed to create a role |
108
|
|
|
* @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException if the Role already has a Role Draft that will need to be removed first |
109
|
|
|
* @throws \eZ\Publish\API\Repository\Exceptions\LimitationValidationException if a policy limitation in the $roleCreateStruct is not valid |
110
|
|
|
* |
111
|
|
|
* @param \eZ\Publish\API\Repository\Values\User\Role $role |
112
|
|
|
* |
113
|
|
|
* @return \eZ\Publish\API\Repository\Values\User\RoleDraft |
114
|
|
|
*/ |
115
|
|
|
public function createRoleDraft(APIRole $role) |
116
|
|
|
{ |
117
|
|
|
//TODO |
118
|
|
|
} |
119
|
|
|
|
120
|
|
|
/** |
121
|
|
|
* Loads a role for the given id. |
122
|
|
|
* |
123
|
|
|
* @since 6.0 |
124
|
|
|
* |
125
|
|
|
* @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the authenticated user is not allowed to read this role |
126
|
|
|
* @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException if a role with the given id was not found |
127
|
|
|
* |
128
|
|
|
* @param mixed $id |
129
|
|
|
* |
130
|
|
|
* @return \eZ\Publish\API\Repository\Values\User\RoleDraft |
131
|
|
|
*/ |
132
|
|
|
public function loadRoleDraft($id) |
133
|
|
|
{ |
134
|
|
|
//TODO |
135
|
|
|
} |
136
|
|
|
|
137
|
|
|
/** |
138
|
|
|
* Loads a RoleDraft by the ID of the role it was created from. |
139
|
|
|
* |
140
|
|
|
* @param mixed $roleId ID of the role the draft was created from. |
141
|
|
|
* |
142
|
|
|
* @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the authenticated user is not allowed to read this role |
143
|
|
|
* @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException if a RoleDraft with the given id was not found |
144
|
|
|
* |
145
|
|
|
* @return \eZ\Publish\API\Repository\Values\User\RoleDraft |
146
|
|
|
*/ |
147
|
|
|
public function loadRoleDraftByRoleId($roleId) |
148
|
|
|
{ |
149
|
|
|
// TODO |
150
|
|
|
} |
151
|
|
|
|
152
|
|
|
/** |
153
|
|
|
* Updates the properties of a role draft. |
154
|
|
|
* |
155
|
|
|
* @since 6.0 |
156
|
|
|
* |
157
|
|
|
* @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the authenticated user is not allowed to update a role |
158
|
|
|
* @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException if the identifier of the role already exists |
159
|
|
|
* |
160
|
|
|
* @param \eZ\Publish\API\Repository\Values\User\RoleDraft $roleDraft |
161
|
|
|
* @param \eZ\Publish\API\Repository\Values\User\RoleUpdateStruct $roleUpdateStruct |
162
|
|
|
* |
163
|
|
|
* @return \eZ\Publish\API\Repository\Values\User\RoleDraft |
164
|
|
|
*/ |
165
|
|
|
public function updateRoleDraft(APIRoleDraft $roleDraft, RoleUpdateStruct $roleUpdateStruct) |
166
|
|
|
{ |
167
|
|
|
//TODO |
168
|
|
|
} |
169
|
|
|
|
170
|
|
|
/** |
171
|
|
|
* Adds a new policy to the role draft. |
172
|
|
|
* |
173
|
|
|
* @since 6.0 |
174
|
|
|
* |
175
|
|
|
* @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the authenticated user is not allowed to add a policy |
176
|
|
|
* @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException if limitation of the same type is repeated in policy create |
177
|
|
|
* struct or if limitation is not allowed on module/function |
178
|
|
|
* @throws \eZ\Publish\API\Repository\Exceptions\LimitationValidationException if a limitation in the $policyCreateStruct is not valid |
179
|
|
|
* |
180
|
|
|
* @param \eZ\Publish\API\Repository\Values\User\RoleDraft $roleDraft |
181
|
|
|
* @param \eZ\Publish\API\Repository\Values\User\PolicyCreateStruct $policyCreateStruct |
182
|
|
|
* |
183
|
|
|
* @return \eZ\Publish\API\Repository\Values\User\RoleDraft |
184
|
|
|
*/ |
185
|
|
|
public function addPolicyByRoleDraft(APIRoleDraft $roleDraft, APIPolicyCreateStruct $policyCreateStruct) |
186
|
|
|
{ |
187
|
|
|
//TODO |
188
|
|
|
} |
189
|
|
|
|
190
|
|
|
/** |
191
|
|
|
* Removes a policy from a role draft. |
192
|
|
|
* |
193
|
|
|
* @since 6.0 |
194
|
|
|
* |
195
|
|
|
* |
196
|
|
|
* @param \eZ\Publish\API\Repository\Values\User\RoleDraft $roleDraft |
197
|
|
|
* @param PolicyDraft $policyDraft the policy to remove from the role |
198
|
|
|
* @return APIRoleDraft if the authenticated user is not allowed to remove a policy |
199
|
|
|
*/ |
200
|
|
|
public function removePolicyByRoleDraft(APIRoleDraft $roleDraft, PolicyDraft $policyDraft) |
201
|
|
|
{ |
202
|
|
|
//TODO |
203
|
|
|
} |
204
|
|
|
|
205
|
|
|
/** |
206
|
|
|
* Updates the limitations of a policy. The module and function cannot be changed and |
207
|
|
|
* the limitations are replaced by the ones in $roleUpdateStruct. |
208
|
|
|
* |
209
|
|
|
* @since 6.0 |
210
|
|
|
* |
211
|
|
|
* @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the authenticated user is not allowed to update a policy |
212
|
|
|
* @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException if limitation of the same type is repeated in policy update |
213
|
|
|
* struct or if limitation is not allowed on module/function |
214
|
|
|
* @throws \eZ\Publish\API\Repository\Exceptions\LimitationValidationException if a limitation in the $policyUpdateStruct is not valid |
215
|
|
|
* |
216
|
|
|
* @param \eZ\Publish\API\Repository\Values\User\RoleDraft $roleDraft |
217
|
|
|
* @param \eZ\Publish\API\Repository\Values\User\PolicyDraft $policy |
218
|
|
|
* @param \eZ\Publish\API\Repository\Values\User\PolicyUpdateStruct $policyUpdateStruct |
219
|
|
|
* |
220
|
|
|
* @return \eZ\Publish\API\Repository\Values\User\PolicyDraft |
221
|
|
|
*/ |
222
|
|
|
public function updatePolicyByRoleDraft(APIRoleDraft $roleDraft, PolicyDraft $policy, APIPolicyUpdateStruct $policyUpdateStruct) |
223
|
|
|
{ |
224
|
|
|
//TODO |
225
|
|
|
} |
226
|
|
|
|
227
|
|
|
/** |
228
|
|
|
* Deletes the given role. |
229
|
|
|
* |
230
|
|
|
* @since 6.0 |
231
|
|
|
* |
232
|
|
|
* @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the authenticated user is not allowed to delete this role |
233
|
|
|
* |
234
|
|
|
* @param \eZ\Publish\API\Repository\Values\User\RoleDraft $roleDraft |
235
|
|
|
*/ |
236
|
|
|
public function deleteRoleDraft(APIRoleDraft $roleDraft) |
237
|
|
|
{ |
238
|
|
|
//TODO |
239
|
|
|
} |
240
|
|
|
|
241
|
|
|
/** |
242
|
|
|
* Publishes a given Role draft. |
243
|
|
|
* |
244
|
|
|
* @since 6.0 |
245
|
|
|
* |
246
|
|
|
* @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the authenticated user is not allowed to delete this role |
247
|
|
|
* |
248
|
|
|
* @param \eZ\Publish\API\Repository\Values\User\RoleDraft $roleDraft |
249
|
|
|
*/ |
250
|
|
|
public function publishRoleDraft(APIRoleDraft $roleDraft) |
251
|
|
|
{ |
252
|
|
|
//TODO |
253
|
|
|
} |
254
|
|
|
|
255
|
|
|
/** |
256
|
|
|
* Creates a new Role draft. |
257
|
|
|
* |
258
|
|
|
* @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the authenticated user is not allowed to create a role |
259
|
|
|
* @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException if the name of the role already exists or if limitation of the |
260
|
|
|
* same type is repeated in the policy create struct or if |
261
|
|
|
* limitation is not allowed on module/function |
262
|
|
|
* @throws \eZ\Publish\API\Repository\Exceptions\LimitationValidationException if a policy limitation in the $roleCreateStruct is not valid |
263
|
|
|
* |
264
|
|
|
* @param \eZ\Publish\API\Repository\Values\User\RoleCreateStruct $roleCreateStruct |
265
|
|
|
* |
266
|
|
|
* @return \eZ\Publish\API\Repository\Values\User\RoleDraft |
267
|
|
|
*/ |
268
|
|
|
public function createRole(APIRoleCreateStruct $roleCreateStruct) |
269
|
|
|
{ |
270
|
|
|
$inputMessage = $this->outputVisitor->visit($roleCreateStruct); |
271
|
|
|
$inputMessage->headers['Accept'] = $this->outputVisitor->getMediaType('Role'); |
272
|
|
|
|
273
|
|
|
$result = $this->client->request( |
274
|
|
|
'POST', |
275
|
|
|
$this->requestParser->generate('roles'), |
276
|
|
|
$inputMessage |
277
|
|
|
); |
278
|
|
|
|
279
|
|
|
$createdRole = $this->inputDispatcher->parse($result); |
280
|
|
|
$createdRoleValues = $this->requestParser->parse('role', $createdRole->id); |
|
|
|
|
281
|
|
|
|
282
|
|
|
$createdPolicies = array(); |
283
|
|
|
foreach ($roleCreateStruct->getPolicies() as $policyCreateStruct) { |
284
|
|
|
$inputMessage = $this->outputVisitor->visit($policyCreateStruct); |
285
|
|
|
$inputMessage->headers['Accept'] = $this->outputVisitor->getMediaType('Policy'); |
286
|
|
|
|
287
|
|
|
$result = $this->client->request( |
288
|
|
|
'POST', |
289
|
|
|
$this->requestParser->generate('policies', array('role' => $createdRoleValues['role'])), |
290
|
|
|
$inputMessage |
291
|
|
|
); |
292
|
|
|
|
293
|
|
|
$createdPolicy = $this->inputDispatcher->parse($result); |
294
|
|
|
|
295
|
|
|
// @todo Workaround for missing roleId in Policy XSD definition |
296
|
|
|
$createdPolicyArray = array( |
297
|
|
|
'id' => $createdPolicy->id, |
|
|
|
|
298
|
|
|
'roleId' => $createdRole->id, |
|
|
|
|
299
|
|
|
'module' => $createdPolicy->module, |
|
|
|
|
300
|
|
|
'function' => $createdPolicy->function, |
|
|
|
|
301
|
|
|
); |
302
|
|
|
|
303
|
|
|
$createdPolicy = new Policy($createdPolicyArray); |
304
|
|
|
$createdPolicies[] = $createdPolicy; |
305
|
|
|
} |
306
|
|
|
|
307
|
|
|
return new RoleDraft( |
308
|
|
|
array( |
309
|
|
|
'id' => $createdRole->id, |
|
|
|
|
310
|
|
|
'identifier' => $createdRole->identifier, |
|
|
|
|
311
|
|
|
), |
312
|
|
|
$createdPolicies |
313
|
|
|
); |
314
|
|
|
} |
315
|
|
|
|
316
|
|
|
/** |
317
|
|
|
* Updates the name of the role. |
318
|
|
|
* |
319
|
|
|
* @deprecated since 6.0, use {@see updateRoleDraft} |
320
|
|
|
* |
321
|
|
|
* @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the authenticated user is not allowed to update a role |
322
|
|
|
* @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException if the name of the role already exists |
323
|
|
|
* |
324
|
|
|
* @param \eZ\Publish\API\Repository\Values\User\Role $role |
325
|
|
|
* @param \eZ\Publish\API\Repository\Values\User\RoleUpdateStruct $roleUpdateStruct |
326
|
|
|
* |
327
|
|
|
* @return \eZ\Publish\API\Repository\Values\User\Role |
328
|
|
|
*/ |
329
|
|
|
public function updateRole(APIRole $role, RoleUpdateStruct $roleUpdateStruct) |
330
|
|
|
{ |
331
|
|
|
$inputMessage = $this->outputVisitor->visit($roleUpdateStruct); |
332
|
|
|
$inputMessage->headers['Accept'] = $this->outputVisitor->getMediaType('Role'); |
333
|
|
|
$inputMessage->headers['X-HTTP-Method-Override'] = 'PATCH'; |
334
|
|
|
|
335
|
|
|
$result = $this->client->request( |
336
|
|
|
'POST', |
337
|
|
|
$role->id, |
338
|
|
|
$inputMessage |
339
|
|
|
); |
340
|
|
|
|
341
|
|
|
return $this->inputDispatcher->parse($result); |
342
|
|
|
} |
343
|
|
|
|
344
|
|
|
/** |
345
|
|
|
* Adds a new policy to the role. |
346
|
|
|
* |
347
|
|
|
* @deprecated since 6.0, use {@see addPolicyByRoleDraft} |
348
|
|
|
* |
349
|
|
|
* @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the authenticated user is not allowed to add a policy |
350
|
|
|
* @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException if limitation of the same type is repeated in policy create |
351
|
|
|
* struct or if limitation is not allowed on module/function |
352
|
|
|
* @throws \eZ\Publish\API\Repository\Exceptions\LimitationValidationException if a limitation in the $policyCreateStruct is not valid |
353
|
|
|
* |
354
|
|
|
* @param \eZ\Publish\API\Repository\Values\User\Role $role |
355
|
|
|
* @param \eZ\Publish\API\Repository\Values\User\PolicyCreateStruct $policyCreateStruct |
356
|
|
|
* |
357
|
|
|
* @return \eZ\Publish\API\Repository\Values\User\Role |
358
|
|
|
*/ |
359
|
|
|
public function addPolicy(APIRole $role, APIPolicyCreateStruct $policyCreateStruct) |
360
|
|
|
{ |
361
|
|
|
$values = $this->requestParser->parse('role', $role->id); |
362
|
|
|
$inputMessage = $this->outputVisitor->visit($policyCreateStruct); |
363
|
|
|
$inputMessage->headers['Accept'] = $this->outputVisitor->getMediaType('Policy'); |
364
|
|
|
|
365
|
|
|
$result = $this->client->request( |
366
|
|
|
'POST', |
367
|
|
|
$this->requestParser->generate('policies', array('role' => $values['role'])), |
368
|
|
|
$inputMessage |
369
|
|
|
); |
370
|
|
|
|
371
|
|
|
$createdPolicy = $this->inputDispatcher->parse($result); |
372
|
|
|
|
373
|
|
|
// @todo Workaround for missing roleId in Policy XSD definition |
374
|
|
|
$createdPolicyArray = array( |
375
|
|
|
'id' => $createdPolicy->id, |
|
|
|
|
376
|
|
|
'roleId' => $role->id, |
377
|
|
|
'module' => $createdPolicy->module, |
|
|
|
|
378
|
|
|
'function' => $createdPolicy->function, |
|
|
|
|
379
|
|
|
); |
380
|
|
|
|
381
|
|
|
$createdPolicy = new Policy($createdPolicyArray); |
382
|
|
|
|
383
|
|
|
$existingPolicies = $role->getPolicies(); |
384
|
|
|
$existingPolicies[] = $createdPolicy; |
385
|
|
|
|
386
|
|
|
return new Role( |
387
|
|
|
array( |
388
|
|
|
'id' => $role->id, |
389
|
|
|
'identifier' => $role->identifier, |
390
|
|
|
), |
391
|
|
|
$existingPolicies |
392
|
|
|
); |
393
|
|
|
} |
394
|
|
|
|
395
|
|
|
/** |
396
|
|
|
* Removes a policy from the role. |
397
|
|
|
* |
398
|
|
|
* @deprecated since 5.3, use {@link removePolicyByRoleDraft()} instead. |
399
|
|
|
* |
400
|
|
|
* @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the authenticated user is not allowed to remove a policy |
401
|
|
|
* @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException if policy does not belong to the given role |
402
|
|
|
* |
403
|
|
|
* @param \eZ\Publish\API\Repository\Values\User\Role $role |
404
|
|
|
* @param \eZ\Publish\API\Repository\Values\User\Policy $policy the policy to remove from the role |
405
|
|
|
* |
406
|
|
|
* @return \eZ\Publish\API\Repository\Values\User\Role the updated role |
407
|
|
|
*/ |
408
|
|
|
public function removePolicy(APIRole $role, APIPolicy $policy) |
409
|
|
|
{ |
410
|
|
|
$values = $this->requestParser->parse('role', $role->id); |
411
|
|
|
$response = $this->client->request( |
412
|
|
|
'DELETE', |
413
|
|
|
$this->requestParser->generate( |
414
|
|
|
'policy', |
415
|
|
|
array( |
416
|
|
|
'role' => $values['role'], |
417
|
|
|
'policy' => $policy->id, |
418
|
|
|
) |
419
|
|
|
), |
420
|
|
|
new Message( |
421
|
|
|
// @todo: What media-type should we set here? Actually, it should be |
422
|
|
|
// all expected exceptions + none? Or is "Section" correct, |
423
|
|
|
// since this is what is to be expected by the resource |
424
|
|
|
// identified by the URL? |
425
|
|
|
array('Accept' => $this->outputVisitor->getMediaType('Policy')) |
426
|
|
|
) |
427
|
|
|
); |
428
|
|
|
|
429
|
|
|
if (!empty($response->body)) { |
430
|
|
|
$this->inputDispatcher->parse($response); |
431
|
|
|
} |
432
|
|
|
|
433
|
|
|
return $this->loadRole($role->id); |
434
|
|
|
} |
435
|
|
|
|
436
|
|
|
/** |
437
|
|
|
* Deletes a policy. |
438
|
|
|
* |
439
|
|
|
* @deprecated since 6.0, use {@link removePolicyByRoleDraft()} instead. |
440
|
|
|
* |
441
|
|
|
* @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the authenticated user is not allowed to remove a policy |
442
|
|
|
* |
443
|
|
|
* @param \eZ\Publish\API\Repository\Values\User\Policy $policy the policy to delete |
444
|
|
|
*/ |
445
|
|
|
public function deletePolicy(APIPolicy $policy) |
446
|
|
|
{ |
447
|
|
|
throw new \Exception('@todo: Implement.'); |
448
|
|
|
} |
449
|
|
|
|
450
|
|
|
/** |
451
|
|
|
* Updates the limitations of a policy. The module and function cannot be changed and |
452
|
|
|
* the limitations are replaced by the ones in $roleUpdateStruct. |
453
|
|
|
* |
454
|
|
|
* @deprecated since 6.0, use {@link updatePolicyByRoleDraft()} instead. |
455
|
|
|
* |
456
|
|
|
* @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the authenticated user is not allowed to update a policy |
457
|
|
|
* @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException if limitation of the same type is repeated in policy update |
458
|
|
|
* struct or if limitation is not allowed on module/function |
459
|
|
|
* @throws \eZ\Publish\API\Repository\Exceptions\LimitationValidationException if a limitation in the $policyUpdateStruct is not valid |
460
|
|
|
* |
461
|
|
|
* @param \eZ\Publish\API\Repository\Values\User\PolicyUpdateStruct $policyUpdateStruct |
462
|
|
|
* @param \eZ\Publish\API\Repository\Values\User\Policy $policy |
463
|
|
|
* |
464
|
|
|
* @return \eZ\Publish\API\Repository\Values\User\Policy |
465
|
|
|
*/ |
466
|
|
|
public function updatePolicy(APIPolicy $policy, APIPolicyUpdateStruct $policyUpdateStruct) |
467
|
|
|
{ |
468
|
|
|
$values = $this->requestParser->parse('role', $policy->roleId); |
469
|
|
|
$inputMessage = $this->outputVisitor->visit($policyUpdateStruct); |
470
|
|
|
$inputMessage->headers['Accept'] = $this->outputVisitor->getMediaType('Policy'); |
471
|
|
|
$inputMessage->headers['X-HTTP-Method-Override'] = 'PATCH'; |
472
|
|
|
|
473
|
|
|
$result = $this->client->request( |
474
|
|
|
'POST', |
475
|
|
|
$this->requestParser->generate( |
476
|
|
|
'policy', |
477
|
|
|
array( |
478
|
|
|
'role' => $values['role'], |
479
|
|
|
'policy' => $policy->id, |
480
|
|
|
) |
481
|
|
|
), |
482
|
|
|
$inputMessage |
483
|
|
|
); |
484
|
|
|
|
485
|
|
|
return $this->inputDispatcher->parse($result); |
486
|
|
|
} |
487
|
|
|
|
488
|
|
|
/** |
489
|
|
|
* Loads a role for the given id. |
490
|
|
|
* |
491
|
|
|
* @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the authenticated user is not allowed to read this role |
492
|
|
|
* @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException if a role with the given name was not found |
493
|
|
|
* |
494
|
|
|
* @param mixed $id |
495
|
|
|
* |
496
|
|
|
* @return \eZ\Publish\API\Repository\Values\User\Role |
497
|
|
|
*/ |
498
|
|
|
public function loadRole($id) |
499
|
|
|
{ |
500
|
|
|
$response = $this->client->request( |
501
|
|
|
'GET', |
502
|
|
|
$id, |
503
|
|
|
new Message( |
504
|
|
|
array('Accept' => $this->outputVisitor->getMediaType('Role')) |
505
|
|
|
) |
506
|
|
|
); |
507
|
|
|
|
508
|
|
|
$loadedRole = $this->inputDispatcher->parse($response); |
509
|
|
|
$loadedRoleValues = $this->requestParser->parse('role', $loadedRole->id); |
|
|
|
|
510
|
|
|
$response = $this->client->request( |
511
|
|
|
'GET', |
512
|
|
|
$this->requestParser->generate('policies', array('role' => $loadedRoleValues['role'])), |
513
|
|
|
new Message( |
514
|
|
|
array('Accept' => $this->outputVisitor->getMediaType('PolicyList')) |
515
|
|
|
) |
516
|
|
|
); |
517
|
|
|
|
518
|
|
|
$policies = $this->inputDispatcher->parse($response); |
519
|
|
|
|
520
|
|
|
return new Role( |
521
|
|
|
array( |
522
|
|
|
'id' => $loadedRole->id, |
|
|
|
|
523
|
|
|
'identifier' => $loadedRole->identifier, |
|
|
|
|
524
|
|
|
), |
525
|
|
|
$policies |
526
|
|
|
); |
527
|
|
|
} |
528
|
|
|
|
529
|
|
|
/** |
530
|
|
|
* Loads a role for the given name. |
531
|
|
|
* |
532
|
|
|
* @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the authenticated user is not allowed to read this role |
533
|
|
|
* @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException if a role with the given name was not found |
534
|
|
|
* |
535
|
|
|
* @param string $name |
536
|
|
|
* |
537
|
|
|
* @return \eZ\Publish\API\Repository\Values\User\Role |
538
|
|
|
*/ |
539
|
|
|
public function loadRoleByIdentifier($name) |
540
|
|
|
{ |
541
|
|
|
$response = $this->client->request( |
542
|
|
|
'GET', |
543
|
|
|
$this->requestParser->generate('roleByIdentifier', array('role' => $name)), |
544
|
|
|
new Message( |
545
|
|
|
array('Accept' => $this->outputVisitor->getMediaType('RoleList')) |
546
|
|
|
) |
547
|
|
|
); |
548
|
|
|
|
549
|
|
|
$result = $this->inputDispatcher->parse($response); |
550
|
|
|
|
551
|
|
|
return reset($result); |
552
|
|
|
} |
553
|
|
|
|
554
|
|
|
/** |
555
|
|
|
* Loads all roles. |
556
|
|
|
* |
557
|
|
|
* @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the authenticated user is not allowed to read the roles |
558
|
|
|
* |
559
|
|
|
* @return \eZ\Publish\API\Repository\Values\User\Role[] |
560
|
|
|
*/ |
561
|
|
View Code Duplication |
public function loadRoles() |
562
|
|
|
{ |
563
|
|
|
$response = $this->client->request( |
564
|
|
|
'GET', |
565
|
|
|
$this->requestParser->generate('roles'), |
566
|
|
|
new Message( |
567
|
|
|
array('Accept' => $this->outputVisitor->getMediaType('RoleList')) |
568
|
|
|
) |
569
|
|
|
); |
570
|
|
|
|
571
|
|
|
return $this->inputDispatcher->parse($response); |
|
|
|
|
572
|
|
|
} |
573
|
|
|
|
574
|
|
|
/** |
575
|
|
|
* Deletes the given role. |
576
|
|
|
* |
577
|
|
|
* @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the authenticated user is not allowed to delete this role |
578
|
|
|
* |
579
|
|
|
* @param \eZ\Publish\API\Repository\Values\User\Role $role |
580
|
|
|
*/ |
581
|
|
View Code Duplication |
public function deleteRole(APIRole $role) |
582
|
|
|
{ |
583
|
|
|
$response = $this->client->request( |
584
|
|
|
'DELETE', |
585
|
|
|
$role->id, |
586
|
|
|
new Message( |
587
|
|
|
// @todo: What media-type should we set here? Actually, it should be |
588
|
|
|
// all expected exceptions + none? Or is "Section" correct, |
589
|
|
|
// since this is what is to be expected by the resource |
590
|
|
|
// identified by the URL? |
591
|
|
|
array('Accept' => $this->outputVisitor->getMediaType('Role')) |
592
|
|
|
) |
593
|
|
|
); |
594
|
|
|
|
595
|
|
|
if (!empty($response->body)) { |
596
|
|
|
$this->inputDispatcher->parse($response); |
597
|
|
|
} |
598
|
|
|
} |
599
|
|
|
|
600
|
|
|
/** |
601
|
|
|
* Loads all policies from roles which are assigned to a user or to user groups to which the user belongs. |
602
|
|
|
* |
603
|
|
|
* @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException if a user with the given id was not found |
604
|
|
|
* |
605
|
|
|
* @param mixed $userId |
606
|
|
|
* |
607
|
|
|
* @return \eZ\Publish\API\Repository\Values\User\Policy[] |
608
|
|
|
*/ |
609
|
|
View Code Duplication |
public function loadPoliciesByUserId($userId) |
610
|
|
|
{ |
611
|
|
|
$values = $this->requestParser->parse('user', $userId); |
612
|
|
|
$response = $this->client->request( |
613
|
|
|
'GET', |
614
|
|
|
$this->requestParser->generate('userPolicies', array('user' => $values['user'])), |
615
|
|
|
new Message( |
616
|
|
|
array('Accept' => $this->outputVisitor->getMediaType('PolicyList')) |
617
|
|
|
) |
618
|
|
|
); |
619
|
|
|
|
620
|
|
|
return $this->inputDispatcher->parse($response); |
|
|
|
|
621
|
|
|
} |
622
|
|
|
|
623
|
|
|
/** |
624
|
|
|
* Assigns a role to the given user group. |
625
|
|
|
* |
626
|
|
|
* @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the authenticated user is not allowed to assign a role |
627
|
|
|
* @throws \eZ\Publish\API\Repository\Exceptions\LimitationValidationException if $roleLimitation is not valid |
628
|
|
|
* |
629
|
|
|
* @param \eZ\Publish\API\Repository\Values\User\Role $role |
630
|
|
|
* @param \eZ\Publish\API\Repository\Values\User\UserGroup $userGroup |
631
|
|
|
* @param \eZ\Publish\API\Repository\Values\User\Limitation\RoleLimitation $roleLimitation an optional role limitation (which is either a subtree limitation or section limitation) |
632
|
|
|
*/ |
633
|
|
View Code Duplication |
public function assignRoleToUserGroup(APIRole $role, UserGroup $userGroup, RoleLimitation $roleLimitation = null) |
634
|
|
|
{ |
635
|
|
|
$roleAssignment = new RoleAssignment( |
636
|
|
|
array( |
637
|
|
|
'role' => $role, |
638
|
|
|
'limitation' => $roleLimitation, |
639
|
|
|
) |
640
|
|
|
); |
641
|
|
|
|
642
|
|
|
$inputMessage = $this->outputVisitor->visit($roleAssignment); |
643
|
|
|
$inputMessage->headers['Accept'] = $this->outputVisitor->getMediaType('RoleAssignmentList'); |
644
|
|
|
|
645
|
|
|
$result = $this->client->request( |
646
|
|
|
'POST', |
647
|
|
|
$this->requestParser->generate('groupRoleAssignments', array('group' => $userGroup->id)), |
648
|
|
|
$inputMessage |
649
|
|
|
); |
650
|
|
|
|
651
|
|
|
$this->inputDispatcher->parse($result); |
652
|
|
|
} |
653
|
|
|
|
654
|
|
|
/** |
655
|
|
|
* removes a role from the given user group. |
656
|
|
|
* |
657
|
|
|
* @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the authenticated user is not allowed to remove a role |
658
|
|
|
* @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException If the role is not assigned to the given user group |
659
|
|
|
* |
660
|
|
|
* @param \eZ\Publish\API\Repository\Values\User\Role $role |
661
|
|
|
* @param \eZ\Publish\API\Repository\Values\User\UserGroup $userGroup |
662
|
|
|
*/ |
663
|
|
View Code Duplication |
public function unassignRoleFromUserGroup(APIRole $role, UserGroup $userGroup) |
664
|
|
|
{ |
665
|
|
|
$values = $this->requestParser->parse('group', $userGroup->id); |
666
|
|
|
$userGroupId = $values['group']; |
667
|
|
|
|
668
|
|
|
$values = $this->requestParser->parse('role', $role->id); |
669
|
|
|
$roleId = $values['role']; |
670
|
|
|
|
671
|
|
|
$response = $this->client->request( |
672
|
|
|
'DELETE', |
673
|
|
|
$this->requestParser->generate('groupRoleAssignment', array('group' => $userGroupId, 'role' => $roleId)), |
674
|
|
|
new Message( |
675
|
|
|
// @todo: What media-type should we set here? Actually, it should be |
676
|
|
|
// all expected exceptions + none? Or is "Section" correct, |
677
|
|
|
// since this is what is to be expected by the resource |
678
|
|
|
// identified by the URL? |
679
|
|
|
array('Accept' => $this->outputVisitor->getMediaType('RoleAssignmentList')) |
680
|
|
|
) |
681
|
|
|
); |
682
|
|
|
|
683
|
|
|
if (!empty($response->body)) { |
684
|
|
|
$this->inputDispatcher->parse($response); |
685
|
|
|
} |
686
|
|
|
} |
687
|
|
|
|
688
|
|
|
/** |
689
|
|
|
* Assigns a role to the given user. |
690
|
|
|
* |
691
|
|
|
* @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the authenticated user is not allowed to assign a role |
692
|
|
|
* @throws \eZ\Publish\API\Repository\Exceptions\LimitationValidationException if $roleLimitation is not valid |
693
|
|
|
* |
694
|
|
|
* @todo add limitations |
695
|
|
|
* |
696
|
|
|
* @param \eZ\Publish\API\Repository\Values\User\Role $role |
697
|
|
|
* @param \eZ\Publish\API\Repository\Values\User\User $user |
698
|
|
|
* @param \eZ\Publish\API\Repository\Values\User\Limitation\RoleLimitation $roleLimitation an optional role limitation (which is either a subtree limitation or section limitation) |
699
|
|
|
*/ |
700
|
|
View Code Duplication |
public function assignRoleToUser(APIRole $role, User $user, RoleLimitation $roleLimitation = null) |
701
|
|
|
{ |
702
|
|
|
$roleAssignment = new RoleAssignment( |
703
|
|
|
array( |
704
|
|
|
'role' => $role, |
705
|
|
|
'limitation' => $roleLimitation, |
706
|
|
|
) |
707
|
|
|
); |
708
|
|
|
|
709
|
|
|
$inputMessage = $this->outputVisitor->visit($roleAssignment); |
710
|
|
|
$inputMessage->headers['Accept'] = $this->outputVisitor->getMediaType('RoleAssignmentList'); |
711
|
|
|
|
712
|
|
|
$result = $this->client->request( |
713
|
|
|
'POST', |
714
|
|
|
$this->requestParser->generate('userRoleAssignments', array('user' => $user->id)), |
715
|
|
|
$inputMessage |
716
|
|
|
); |
717
|
|
|
|
718
|
|
|
$this->inputDispatcher->parse($result); |
719
|
|
|
} |
720
|
|
|
|
721
|
|
|
/** |
722
|
|
|
* removes a role from the given user. |
723
|
|
|
* |
724
|
|
|
* @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the authenticated user is not allowed to remove a role |
725
|
|
|
* @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException If the role is not assigned to the user |
726
|
|
|
* |
727
|
|
|
* @param \eZ\Publish\API\Repository\Values\User\Role $role |
728
|
|
|
* @param \eZ\Publish\API\Repository\Values\User\User $user |
729
|
|
|
*/ |
730
|
|
View Code Duplication |
public function unassignRoleFromUser(APIRole $role, User $user) |
731
|
|
|
{ |
732
|
|
|
$values = $this->requestParser->parse('user', $user->id); |
733
|
|
|
$userId = $values['user']; |
734
|
|
|
|
735
|
|
|
$values = $this->requestParser->parse('role', $role->id); |
736
|
|
|
$roleId = $values['role']; |
737
|
|
|
|
738
|
|
|
$response = $this->client->request( |
739
|
|
|
'DELETE', |
740
|
|
|
$this->requestParser->generate('userRoleAssignment', array('user' => $userId, 'role' => $roleId)), |
741
|
|
|
new Message( |
742
|
|
|
// @todo: What media-type should we set here? Actually, it should be |
743
|
|
|
// all expected exceptions + none? Or is "Section" correct, |
744
|
|
|
// since this is what is to be expected by the resource |
745
|
|
|
// identified by the URL? |
746
|
|
|
array('Accept' => $this->outputVisitor->getMediaType('RoleAssignmentList')) |
747
|
|
|
) |
748
|
|
|
); |
749
|
|
|
|
750
|
|
|
if (!empty($response->body)) { |
751
|
|
|
$this->inputDispatcher->parse($response); |
752
|
|
|
} |
753
|
|
|
} |
754
|
|
|
|
755
|
|
|
/** |
756
|
|
|
* Removes the given role assignment. |
757
|
|
|
* |
758
|
|
|
* @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the authenticated user is not allowed to remove a role assignment |
759
|
|
|
* |
760
|
|
|
* @param \eZ\Publish\API\Repository\Values\User\RoleAssignment $roleAssignment |
761
|
|
|
*/ |
762
|
|
|
public function removeRoleAssignment(APIRoleAssignment $roleAssignment) |
763
|
|
|
{ |
764
|
|
|
throw new \Exception('@todo: Implement.'); |
765
|
|
|
} |
766
|
|
|
|
767
|
|
|
/** |
768
|
|
|
* Loads a user assignment for the given id. |
769
|
|
|
* |
770
|
|
|
* @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the authenticated user is not allowed to read this role |
771
|
|
|
* @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException If the role assignment was not found |
772
|
|
|
* |
773
|
|
|
* @param mixed $roleAssignmentId |
774
|
|
|
* |
775
|
|
|
* @return \eZ\Publish\API\Repository\Values\User\RoleAssignment |
776
|
|
|
*/ |
777
|
|
|
public function loadRoleAssignment($roleAssignmentId) |
778
|
|
|
{ |
779
|
|
|
throw new \Exception('@todo: Implement.'); |
780
|
|
|
} |
781
|
|
|
|
782
|
|
|
/** |
783
|
|
|
* Returns the assigned user and user groups to this role. |
784
|
|
|
* |
785
|
|
|
* @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the authenticated user is not allowed to read a role |
786
|
|
|
* |
787
|
|
|
* @param \eZ\Publish\API\Repository\Values\User\Role $role |
788
|
|
|
* |
789
|
|
|
* @return \eZ\Publish\API\Repository\Values\User\RoleAssignment[] |
790
|
|
|
*/ |
791
|
|
|
public function getRoleAssignments(APIRole $role) |
792
|
|
|
{ |
793
|
|
|
throw new \Exception('@todo: Implement.'); |
794
|
|
|
} |
795
|
|
|
|
796
|
|
|
/** |
797
|
|
|
* @see \eZ\Publish\API\Repository\RoleService::getRoleAssignmentsForUser() |
798
|
|
|
*/ |
799
|
|
View Code Duplication |
public function getRoleAssignmentsForUser(User $user, $inherited = false) |
800
|
|
|
{ |
801
|
|
|
$response = $this->client->request( |
802
|
|
|
'GET', |
803
|
|
|
$this->requestParser->generate('userRoleAssignments'), |
804
|
|
|
new Message( |
805
|
|
|
array('Accept' => $this->outputVisitor->getMediaType('RoleAssignmentList')) |
806
|
|
|
) |
807
|
|
|
); |
808
|
|
|
|
809
|
|
|
$roleAssignments = $this->inputDispatcher->parse($response); |
810
|
|
|
|
811
|
|
|
$userRoleAssignments = array(); |
812
|
|
|
foreach ($roleAssignments as $roleAssignment) { |
|
|
|
|
813
|
|
|
$userRoleAssignments[] = new UserRoleAssignment( |
814
|
|
|
array( |
815
|
|
|
'limitation' => $roleAssignment->getRoleLimitation(), |
816
|
|
|
'role' => $roleAssignment->getRole(), |
817
|
|
|
'user' => $user, |
818
|
|
|
) |
819
|
|
|
); |
820
|
|
|
} |
821
|
|
|
|
822
|
|
|
return $userRoleAssignments; |
823
|
|
|
} |
824
|
|
|
|
825
|
|
|
/** |
826
|
|
|
* Returns the roles assigned to the given user group. |
827
|
|
|
* |
828
|
|
|
* @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the authenticated user is not allowed to read a user group |
829
|
|
|
* |
830
|
|
|
* @param \eZ\Publish\API\Repository\Values\User\UserGroup $userGroup |
831
|
|
|
* |
832
|
|
|
* @return \eZ\Publish\API\Repository\Values\User\UserGroupRoleAssignment[] |
833
|
|
|
*/ |
834
|
|
View Code Duplication |
public function getRoleAssignmentsForUserGroup(UserGroup $userGroup) |
835
|
|
|
{ |
836
|
|
|
$response = $this->client->request( |
837
|
|
|
'GET', |
838
|
|
|
$this->requestParser->generate('groupRoleAssignments'), |
839
|
|
|
new Message( |
840
|
|
|
array('Accept' => $this->outputVisitor->getMediaType('RoleAssignmentList')) |
841
|
|
|
) |
842
|
|
|
); |
843
|
|
|
|
844
|
|
|
$roleAssignments = $this->inputDispatcher->parse($response); |
845
|
|
|
|
846
|
|
|
$userGroupRoleAssignments = array(); |
847
|
|
|
foreach ($roleAssignments as $roleAssignment) { |
|
|
|
|
848
|
|
|
$userGroupRoleAssignments[] = new UserGroupRoleAssignment( |
849
|
|
|
array( |
850
|
|
|
'limitation' => $roleAssignment->getRoleLimitation(), |
851
|
|
|
'role' => $roleAssignment->getRole(), |
852
|
|
|
'userGroup' => $userGroup, |
853
|
|
|
) |
854
|
|
|
); |
855
|
|
|
} |
856
|
|
|
|
857
|
|
|
return $userGroupRoleAssignments; |
858
|
|
|
} |
859
|
|
|
|
860
|
|
|
/** |
861
|
|
|
* Instantiates a role create class. |
862
|
|
|
* |
863
|
|
|
* @param string $name |
864
|
|
|
* |
865
|
|
|
* @return \eZ\Publish\API\Repository\Values\User\RoleCreateStruct |
866
|
|
|
*/ |
867
|
|
|
public function newRoleCreateStruct($name) |
868
|
|
|
{ |
869
|
|
|
return new Values\User\RoleCreateStruct($name); |
870
|
|
|
} |
871
|
|
|
|
872
|
|
|
/** |
873
|
|
|
* Instantiates a policy create class. |
874
|
|
|
* |
875
|
|
|
* @param string $module |
876
|
|
|
* @param string $function |
877
|
|
|
* |
878
|
|
|
* @return \eZ\Publish\API\Repository\Values\User\PolicyCreateStruct |
879
|
|
|
*/ |
880
|
|
|
public function newPolicyCreateStruct($module, $function) |
881
|
|
|
{ |
882
|
|
|
return new PolicyCreateStruct($module, $function); |
883
|
|
|
} |
884
|
|
|
|
885
|
|
|
/** |
886
|
|
|
* Instantiates a policy update class. |
887
|
|
|
* |
888
|
|
|
* @return \eZ\Publish\API\Repository\Values\User\PolicyUpdateStruct |
889
|
|
|
*/ |
890
|
|
|
public function newPolicyUpdateStruct() |
891
|
|
|
{ |
892
|
|
|
return new PolicyUpdateStruct(); |
893
|
|
|
} |
894
|
|
|
|
895
|
|
|
/** |
896
|
|
|
* Instantiates a policy update class. |
897
|
|
|
* |
898
|
|
|
* @return \eZ\Publish\API\Repository\Values\User\RoleUpdateStruct |
899
|
|
|
*/ |
900
|
|
|
public function newRoleUpdateStruct() |
901
|
|
|
{ |
902
|
|
|
return new RoleUpdateStruct(); |
903
|
|
|
} |
904
|
|
|
|
905
|
|
|
/** |
906
|
|
|
* Returns the LimitationType registered with the given identifier. |
907
|
|
|
* |
908
|
|
|
* @param string $identifier |
909
|
|
|
* |
910
|
|
|
* @return \eZ\Publish\SPI\Limitation\Type |
911
|
|
|
* |
912
|
|
|
* @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException if there is no LimitationType with $identifier |
913
|
|
|
*/ |
914
|
|
|
public function getLimitationType($identifier) |
915
|
|
|
{ |
916
|
|
|
throw new \eZ\Publish\API\Repository\Exceptions\NotImplementedException(__METHOD__); |
917
|
|
|
} |
918
|
|
|
|
919
|
|
|
/** |
920
|
|
|
* Returns the LimitationType's assigned to a given module/function. |
921
|
|
|
* |
922
|
|
|
* Typically used for: |
923
|
|
|
* - Internal validation limitation value use on Policies |
924
|
|
|
* - Role admin gui for editing policy limitations incl list limitation options via valueSchema() |
925
|
|
|
* |
926
|
|
|
* @param string $module Legacy name of "controller", it's a unique identifier like "content" |
927
|
|
|
* @param string $function Legacy name of a controller "action", it's a unique within the controller like "read" |
928
|
|
|
* |
929
|
|
|
* @return \eZ\Publish\SPI\Limitation\Type[] |
930
|
|
|
* |
931
|
|
|
* @throws \eZ\Publish\API\Repository\Exceptions\BadStateException If module/function to limitation type mapping |
932
|
|
|
* refers to a non existing identifier. |
933
|
|
|
*/ |
934
|
|
|
public function getLimitationTypesByModuleFunction($module, $function) |
935
|
|
|
{ |
936
|
|
|
throw new \eZ\Publish\API\Repository\Exceptions\NotImplementedException(__METHOD__); |
937
|
|
|
} |
938
|
|
|
} |
939
|
|
|
|
Since your code implements the magic getter
_get
, this function will be called for any read access on an undefined variable. You can add the@property
annotation to your class or interface to document the existence of this variable.If the property has read access only, you can use the @property-read annotation instead.
Of course, you may also just have mistyped another name, in which case you should fix the error.
See also the PhpDoc documentation for @property.