Exponential 5.x Kernel 7.5.40 Exponential New Stack (Symfony-based) Kernel — PHP Class Reference

Core/REST/Server/Controller/Role.php
Go to the documentation of this file.
1 <?php
2
7 namespace eZ\Publish\Core\REST\Server\Controller;
8
9 use eZ\Publish\API\Repository\Exceptions\LimitationValidationException;
10 use eZ\Publish\API\Repository\Exceptions\NotFoundException;
11 use eZ\Publish\Core\Base\Exceptions\ForbiddenException;
12 use eZ\Publish\Core\Base\Exceptions\InvalidArgumentException;
13 use eZ\Publish\Core\Base\Exceptions\UnauthorizedException;
14 use eZ\Publish\Core\REST\Common\Message;
15 use eZ\Publish\Core\REST\Common\Exceptions;
16 use eZ\Publish\Core\REST\Server\Exceptions\BadRequestException;
17 use eZ\Publish\Core\REST\Server\Values;
18 use eZ\Publish\Core\REST\Server\Controller as RestController;
19 use eZ\Publish\API\Repository\RoleService;
20 use eZ\Publish\API\Repository\UserService;
21 use eZ\Publish\API\Repository\LocationService;
22 use eZ\Publish\API\Repository\Values\User\RoleCreateStruct;
23 use eZ\Publish\API\Repository\Values\User\RoleUpdateStruct;
24 use eZ\Publish\API\Repository\Exceptions\NotFoundException as APINotFoundException;
25 use Symfony\Component\HttpFoundation\Request;
26
30 class Role extends RestController
31 {
37 protected $roleService;
38
44 protected $userService;
45
51 protected $locationService;
52
60 public function __construct(
61 RoleService $roleService,
62 UserService $userService,
63 LocationService $locationService
64 ) {
65 $this->roleService = $roleService;
66 $this->userService = $userService;
67 $this->locationService = $locationService;
68 }
69
77 public function createRole(Request $request)
78 {
79 $publish = (
80 !$request->query->has('publish') ||
81 ($request->query->has('publish') && $request->query->get('publish') === 'true')
82 );
83
84 try {
85 $roleDraft = $this->roleService->createRole(
86 $this->inputDispatcher->parse(
87 new Message(
88 [
89 'Content-Type' => $request->headers->get('Content-Type'),
90 // @todo Needs refactoring! Temporary solution so parser has access to get parameters
91 '__publish' => $publish,
92 ],
93 $request->getContent()
94 )
95 )
96 );
97 } catch (InvalidArgumentException $e) {
98 throw new ForbiddenException($e->getMessage());
99 } catch (UnauthorizedException $e) {
100 throw new ForbiddenException($e->getMessage());
101 } catch (LimitationValidationException $e) {
102 throw new BadRequestException($e->getMessage());
103 } catch (Exceptions\Parser $e) {
104 throw new BadRequestException($e->getMessage());
105 }
106
107 if ($publish) {
108 @trigger_error(
109 "Create and publish role in the same operation is deprecated, and will be removed in the future.\n" .
110 'Instead, publish the role draft using Role::publishRoleDraft().',
111 E_USER_DEPRECATED
112 );
113
114 $this->roleService->publishRoleDraft($roleDraft);
115
116 $role = $this->roleService->loadRole($roleDraft->id);
117
118 return new Values\CreatedRole(['role' => new Values\RestRole($role)]);
119 }
120
121 return new Values\CreatedRole(['role' => new Values\RestRole($roleDraft)]);
122 }
123
135 public function createRoleDraft($roleId, Request $request)
136 {
137 try {
138 $roleDraft = $this->roleService->createRoleDraft(
139 $this->roleService->loadRole($roleId)
140 );
141 } catch (InvalidArgumentException $e) {
142 throw new ForbiddenException($e->getMessage());
143 } catch (UnauthorizedException $e) {
144 throw new ForbiddenException($e->getMessage());
145 } catch (LimitationValidationException $e) {
146 throw new BadRequestException($e->getMessage());
147 } catch (Exceptions\Parser $e) {
148 throw new BadRequestException($e->getMessage());
149 }
150
151 return new Values\CreatedRole(['role' => new Values\RestRole($roleDraft)]);
152 }
153
159 public function listRoles(Request $request)
160 {
161 $roles = [];
162 if ($request->query->has('identifier')) {
163 try {
164 $role = $this->roleService->loadRoleByIdentifier($request->query->get('identifier'));
165 $roles[] = $role;
166 } catch (APINotFoundException $e) {
167 // Do nothing
168 }
169 } else {
170 $offset = $request->query->has('offset') ? (int)$request->query->get('offset') : 0;
171 $limit = $request->query->has('limit') ? (int)$request->query->get('limit') : -1;
172
173 $roles = array_slice(
174 $this->roleService->loadRoles(),
175 $offset >= 0 ? $offset : 0,
176 $limit >= 0 ? $limit : null
177 );
178 }
179
180 return new Values\RoleList($roles, $request->getPathInfo());
181 }
182
190 public function loadRole($roleId)
191 {
192 return $this->roleService->loadRole($roleId);
193 }
194
202 public function loadRoleDraft($roleId)
203 {
204 try {
205 // First try to load the draft for given role.
206 return $this->roleService->loadRoleDraftByRoleId($roleId);
207 } catch (NotFoundException $e) {
208 // We might want a newly created role, so try to load it by its ID.
209 // loadRoleDraft() might throw a NotFoundException (wrong $roleId). If so, let it bubble up.
210 return $this->roleService->loadRoleDraft($roleId);
211 }
212 }
213
221 public function updateRole($roleId, Request $request)
222 {
223 $createStruct = $this->inputDispatcher->parse(
224 new Message(
225 ['Content-Type' => $request->headers->get('Content-Type')],
226 $request->getContent()
227 )
228 );
229
230 return $this->roleService->updateRole(
231 $this->roleService->loadRole($roleId),
232 $this->mapToUpdateStruct($createStruct)
233 );
234 }
235
243 public function updateRoleDraft($roleId, Request $request)
244 {
245 $createStruct = $this->inputDispatcher->parse(
246 new Message(
247 ['Content-Type' => $request->headers->get('Content-Type')],
248 $request->getContent()
249 )
250 );
251
252 try {
253 // First try to load the draft for given role.
254 $roleDraft = $this->roleService->loadRoleDraftByRoleId($roleId);
255 } catch (NotFoundException $e) {
256 // We might want a newly created role, so try to load it by its ID.
257 // loadRoleDraft() might throw a NotFoundException (wrong $roleId). If so, let it bubble up.
258 $roleDraft = $this->roleService->loadRoleDraft($roleId);
259 }
260
261 return $this->roleService->updateRoleDraft($roleDraft, $this->mapToUpdateStruct($createStruct));
262 }
263
271 public function publishRoleDraft($roleId)
272 {
273 try {
274 // First try to load the draft for given role.
275 $roleDraft = $this->roleService->loadRoleDraftByRoleId($roleId);
276 } catch (NotFoundException $e) {
277 // We might want a newly created role, so try to load it by its ID.
278 // loadRoleDraft() might throw a NotFoundException (wrong $roleId). If so, let it bubble up.
279 $roleDraft = $this->roleService->loadRoleDraft($roleId);
280 }
281
282 $this->roleService->publishRoleDraft($roleDraft);
283
284 $role = $this->roleService->loadRole($roleId);
285
286 return new Values\PublishedRole(['role' => new Values\RestRole($role)]);
287 }
288
296 public function deleteRole($roleId)
297 {
298 $this->roleService->deleteRole(
299 $this->roleService->loadRole($roleId)
300 );
301
302 return new Values\NoContent();
303 }
304
314 public function deleteRoleDraft($roleId)
315 {
316 $this->roleService->deleteRoleDraft(
317 $this->roleService->loadRoleDraft($roleId)
318 );
319
320 return new Values\NoContent();
321 }
322
330 public function loadPolicies($roleId, Request $request)
331 {
332 $loadedRole = $this->roleService->loadRole($roleId);
333
334 return new Values\PolicyList($loadedRole->getPolicies(), $request->getPathInfo());
335 }
336
344 public function deletePolicies($roleId)
345 {
346 $loadedRole = $this->roleService->loadRole($roleId);
347
348 foreach ($loadedRole->getPolicies() as $policy) {
349 $this->roleService->deletePolicy($policy);
350 }
351
352 return new Values\NoContent();
353 }
354
365 public function loadPolicy($roleId, $policyId, Request $request)
366 {
367 $loadedRole = $this->roleService->loadRole($roleId);
368 foreach ($loadedRole->getPolicies() as $policy) {
369 if ($policy->id == $policyId) {
370 return $policy;
371 }
372 }
373
374 throw new Exceptions\NotFoundException("Policy not found: '{$request->getPathInfo()}'.");
375 }
376
384 public function addPolicy($roleId, Request $request)
385 {
386 $createStruct = $this->inputDispatcher->parse(
387 new Message(
388 ['Content-Type' => $request->headers->get('Content-Type')],
389 $request->getContent()
390 )
391 );
392
393 try {
394 // First try to treat $roleId as a role draft ID.
395 $role = $this->roleService->addPolicyByRoleDraft(
396 $this->roleService->loadRoleDraft($roleId),
397 $createStruct
398 );
399 } catch (NotFoundException $e) {
400 // Then try to treat $roleId as a role ID.
401 $role = $this->roleService->addPolicy(
402 $this->roleService->loadRole($roleId),
403 $createStruct
404 );
405 } catch (LimitationValidationException $e) {
406 throw new BadRequestException($e->getMessage());
407 }
408
409 return new Values\CreatedPolicy(
410 [
411 'policy' => $this->getLastAddedPolicy($role),
412 ]
413 );
414 }
415
426 public function addPolicyByRoleDraft($roleId, Request $request)
427 {
428 $createStruct = $this->inputDispatcher->parse(
429 new Message(
430 ['Content-Type' => $request->headers->get('Content-Type')],
431 $request->getContent()
432 )
433 );
434
435 try {
436 $role = $this->roleService->addPolicyByRoleDraft(
437 $this->roleService->loadRoleDraft($roleId),
438 $createStruct
439 );
440 } catch (LimitationValidationException $e) {
441 throw new BadRequestException($e->getMessage());
442 }
443
444 return new Values\CreatedPolicy(
445 [
446 'policy' => $this->getLastAddedPolicy($role),
447 ]
448 );
449 }
450
461 private function getLastAddedPolicy($role)
462 {
463 $policies = $role->getPolicies();
464
465 $policyToReturn = $policies[0];
466 for ($i = 1, $count = count($policies); $i < $count; ++$i) {
467 if ($policies[$i]->id > $policyToReturn->id) {
468 $policyToReturn = $policies[$i];
469 }
470 }
471
472 return $policyToReturn;
473 }
474
485 public function updatePolicy($roleId, $policyId, Request $request)
486 {
487 $updateStruct = $this->inputDispatcher->parse(
488 new Message(
489 ['Content-Type' => $request->headers->get('Content-Type')],
490 $request->getContent()
491 )
492 );
493
494 try {
495 // First try to treat $roleId as a role draft ID.
496 $role = $this->roleService->loadRoleDraft($roleId);
497 foreach ($role->getPolicies() as $policy) {
498 if ($policy->id == $policyId) {
499 try {
500 return $this->roleService->updatePolicy(
501 $policy,
502 $updateStruct
503 );
504 } catch (LimitationValidationException $e) {
505 throw new BadRequestException($e->getMessage());
506 }
507 }
508 }
509 } catch (NotFoundException $e) {
510 // Then try to treat $roleId as a role ID.
511 $role = $this->roleService->loadRole($roleId);
512 foreach ($role->getPolicies() as $policy) {
513 if ($policy->id == $policyId) {
514 try {
515 return $this->roleService->updatePolicy(
516 $policy,
517 $updateStruct
518 );
519 } catch (LimitationValidationException $e) {
520 throw new BadRequestException($e->getMessage());
521 }
522 }
523 }
524 }
525
526 throw new Exceptions\NotFoundException("Policy not found: '{$request->getPathInfo()}'.");
527 }
528
542 public function updatePolicyByRoleDraft($roleId, $policyId, Request $request)
543 {
544 $updateStruct = $this->inputDispatcher->parse(
545 new Message(
546 ['Content-Type' => $request->headers->get('Content-Type')],
547 $request->getContent()
548 )
549 );
550
551 $role = $this->roleService->loadRoleDraft($roleId);
552 foreach ($role->getPolicies() as $policy) {
553 if ($policy->id == $policyId) {
554 try {
555 return $this->roleService->updatePolicy(
556 $policy,
557 $updateStruct
558 );
559 } catch (LimitationValidationException $e) {
560 throw new BadRequestException($e->getMessage());
561 }
562 }
563 }
564
565 throw new Exceptions\NotFoundException("Policy not found: '{$request->getPathInfo()}'.");
566 }
567
578 public function deletePolicy($roleId, $policyId, Request $request)
579 {
580 try {
581 // First try to treat $roleId as a role draft ID.
582 $roleDraft = $this->roleService->loadRoleDraft($roleId);
583
584 $policy = null;
585 foreach ($roleDraft->getPolicies() as $rolePolicy) {
586 if ($rolePolicy->id == $policyId) {
587 $policy = $rolePolicy;
588 break;
589 }
590 }
591
592 if ($policy !== null) {
593 $this->roleService->removePolicyByRoleDraft($roleDraft, $policy);
594
595 return new Values\NoContent();
596 }
597 } catch (NotFoundException $e) {
598 // Then try to treat $roleId as a role ID.
599 $role = $this->roleService->loadRole($roleId);
600
601 $policy = null;
602 foreach ($role->getPolicies() as $rolePolicy) {
603 if ($rolePolicy->id == $policyId) {
604 $policy = $rolePolicy;
605 break;
606 }
607 }
608
609 if ($policy !== null) {
610 $this->roleService->deletePolicy($policy);
611
612 return new Values\NoContent();
613 }
614 }
615
616 throw new Exceptions\NotFoundException("Policy not found: '{$request->getPathInfo()}'.");
617 }
618
632 public function removePolicyByRoleDraft($roleId, $policyId, Request $request)
633 {
634 $roleDraft = $this->roleService->loadRoleDraft($roleId);
635
636 $policy = null;
637 foreach ($roleDraft->getPolicies() as $rolePolicy) {
638 if ($rolePolicy->id == $policyId) {
639 $policy = $rolePolicy;
640 break;
641 }
642 }
643
644 if ($policy !== null) {
645 $this->roleService->removePolicyByRoleDraft($roleDraft, $policy);
646
647 return new Values\NoContent();
648 }
649
650 throw new Exceptions\NotFoundException("Policy not found: '{$request->getPathInfo()}'.");
651 }
652
660 public function assignRoleToUser($userId, Request $request)
661 {
662 $roleAssignment = $this->inputDispatcher->parse(
663 new Message(
664 ['Content-Type' => $request->headers->get('Content-Type')],
665 $request->getContent()
666 )
667 );
668
669 $user = $this->userService->loadUser($userId);
670 $role = $this->roleService->loadRole($roleAssignment->roleId);
671
672 try {
673 $this->roleService->assignRoleToUser($role, $user, $roleAssignment->limitation);
674 } catch (LimitationValidationException $e) {
675 throw new BadRequestException($e->getMessage());
676 }
677
678 $roleAssignments = $this->roleService->getRoleAssignmentsForUser($user);
679
680 return new Values\RoleAssignmentList($roleAssignments, $user->id);
681 }
682
690 public function assignRoleToUserGroup($groupPath, Request $request)
691 {
692 $roleAssignment = $this->inputDispatcher->parse(
693 new Message(
694 ['Content-Type' => $request->headers->get('Content-Type')],
695 $request->getContent()
696 )
697 );
698
699 $groupLocationParts = explode('/', $groupPath);
700 $groupLocation = $this->locationService->loadLocation(array_pop($groupLocationParts));
701 $userGroup = $this->userService->loadUserGroup($groupLocation->contentId);
702
703 $role = $this->roleService->loadRole($roleAssignment->roleId);
704
705 try {
706 $this->roleService->assignRoleToUserGroup($role, $userGroup, $roleAssignment->limitation);
707 } catch (LimitationValidationException $e) {
708 throw new BadRequestException($e->getMessage());
709 }
710
711 $roleAssignments = $this->roleService->getRoleAssignmentsForUserGroup($userGroup);
712
713 return new Values\RoleAssignmentList($roleAssignments, $groupPath, true);
714 }
715
724 public function unassignRoleFromUser($userId, $roleId)
725 {
726 $user = $this->userService->loadUser($userId);
727 $role = $this->roleService->loadRole($roleId);
728
729 $this->roleService->unassignRoleFromUser($role, $user);
730
731 $roleAssignments = $this->roleService->getRoleAssignmentsForUser($user);
732
733 return new Values\RoleAssignmentList($roleAssignments, $user->id);
734 }
735
744 public function unassignRoleFromUserGroup($groupPath, $roleId)
745 {
746 $groupLocationParts = explode('/', $groupPath);
747 $groupLocation = $this->locationService->loadLocation(array_pop($groupLocationParts));
748 $userGroup = $this->userService->loadUserGroup($groupLocation->contentId);
749
750 $role = $this->roleService->loadRole($roleId);
751 $this->roleService->unassignRoleFromUserGroup($role, $userGroup);
752
753 $roleAssignments = $this->roleService->getRoleAssignmentsForUserGroup($userGroup);
754
755 return new Values\RoleAssignmentList($roleAssignments, $groupPath, true);
756 }
757
765 public function loadRoleAssignmentsForUser($userId)
766 {
767 $user = $this->userService->loadUser($userId);
768
769 $roleAssignments = $this->roleService->getRoleAssignmentsForUser($user);
770
771 return new Values\RoleAssignmentList($roleAssignments, $user->id);
772 }
773
781 public function loadRoleAssignmentsForUserGroup($groupPath)
782 {
783 $groupLocationParts = explode('/', $groupPath);
784 $groupLocation = $this->locationService->loadLocation(array_pop($groupLocationParts));
785 $userGroup = $this->userService->loadUserGroup($groupLocation->contentId);
786
787 $roleAssignments = $this->roleService->getRoleAssignmentsForUserGroup($userGroup);
788
789 return new Values\RoleAssignmentList($roleAssignments, $groupPath, true);
790 }
791
802 public function loadRoleAssignmentForUser($userId, $roleId, Request $request)
803 {
804 $user = $this->userService->loadUser($userId);
805 $roleAssignments = $this->roleService->getRoleAssignmentsForUser($user);
806
807 foreach ($roleAssignments as $roleAssignment) {
808 if ($roleAssignment->getRole()->id == $roleId) {
809 return new Values\RestUserRoleAssignment($roleAssignment, $userId);
810 }
811 }
812
813 throw new Exceptions\NotFoundException("Role assignment not found: '{$request->getPathInfo()}'.");
814 }
815
826 public function loadRoleAssignmentForUserGroup($groupPath, $roleId, Request $request)
827 {
828 $groupLocationParts = explode('/', $groupPath);
829 $groupLocation = $this->locationService->loadLocation(array_pop($groupLocationParts));
830 $userGroup = $this->userService->loadUserGroup($groupLocation->contentId);
831
832 $roleAssignments = $this->roleService->getRoleAssignmentsForUserGroup($userGroup);
833 foreach ($roleAssignments as $roleAssignment) {
834 if ($roleAssignment->getRole()->id == $roleId) {
835 return new Values\RestUserGroupRoleAssignment($roleAssignment, $groupPath);
836 }
837 }
838
839 throw new Exceptions\NotFoundException("Role assignment not found: '{$request->getPathInfo()}'.");
840 }
841
847 public function listPoliciesForUser(Request $request)
848 {
849 return new Values\PolicyList(
850 $this->roleService->loadPoliciesByUserId(
851 $request->query->get('userId')
852 ),
853 $request->getPathInfo()
854 );
855 }
856
866 protected function mapToUpdateStruct(RoleCreateStruct $createStruct)
867 {
868 return new RoleUpdateStruct(
869 [
870 'identifier' => $createStruct->identifier,
871 ]
872 );
873 }
874 }
eZ\Publish\API\Repository\Exceptions\InvalidArgumentException
This exception is thrown if a service method is called with an illegal or non appropriate value.
Definition: API/Repository/Exceptions/InvalidArgumentException.php:13
eZ\Publish\API\Repository\Exceptions\LimitationValidationException
This Exception is thrown on create, update or assign policy or role when one or more given limitation...
Definition: API/Repository/Exceptions/LimitationValidationException.php:14
eZ\Publish\API\Repository\Exceptions\NotFoundException
This Exception is thrown if an object referenced by an id or identifier could not be found in the rep...
Definition: API/Repository/Exceptions/NotFoundException.php:16
eZ\Publish\API\Repository\Values\User\RoleCreateStruct
This class is used to create a new role.
Definition: API/Repository/Values/User/RoleCreateStruct.php:15
eZ\Publish\API\Repository\Values\User\RoleUpdateStruct
This class is used to update a role.
Definition: API/Repository/Values/User/RoleUpdateStruct.php:15
eZ\Publish\API\Repository\Values\User\Role
Definition: API/Repository/Values/User/Role.php:19
eZ\Publish\Core\Base\Exceptions\ForbiddenException
Forbidden Exception implementation.
Definition: Core/Base/Exceptions/ForbiddenException.php:17
eZ\Publish\Core\Base\Exceptions\InvalidArgumentException
Invalid Argument Type Exception implementation.
Definition: Core/Base/Exceptions/InvalidArgumentException.php:20
eZ\Publish\Core\Base\Exceptions\UnauthorizedException
UnauthorizedException Exception implementation.
Definition: Core/Base/Exceptions/UnauthorizedException.php:21
eZ\Publish\Core\REST\Common\Exceptions\Parser
Exception thrown if a parser discovers an error.
Definition: REST/Common/Exceptions/Parser.php:15
eZ\Publish\Core\REST\Common\Message
Simple response struct.
Definition: Core/REST/Common/Message.php:13
eZ\Publish\Core\REST\Server\Controller\Role\addPolicyByRoleDraft
addPolicyByRoleDraft($roleId, Request $request)
Adds a policy to a role draft.
Definition: Core/REST/Server/Controller/Role.php:426
eZ\Publish\Core\REST\Server\Controller\Role\unassignRoleFromUser
unassignRoleFromUser($userId, $roleId)
Un-assigns role from user.
Definition: Core/REST/Server/Controller/Role.php:724
eZ\Publish\Core\REST\Server\Controller\Role\loadRoleAssignmentsForUserGroup
loadRoleAssignmentsForUserGroup($groupPath)
Loads role assignments for user group.
Definition: Core/REST/Server/Controller/Role.php:781
eZ\Publish\Core\REST\Server\Controller\Role\loadRoleAssignmentForUserGroup
loadRoleAssignmentForUserGroup($groupPath, $roleId, Request $request)
Returns a role assignment to the given user group.
Definition: Core/REST/Server/Controller/Role.php:826
eZ\Publish\Core\REST\Server\Controller\Role\deleteRole
deleteRole($roleId)
Delete a role by ID.
Definition: Core/REST/Server/Controller/Role.php:296
eZ\Publish\Core\REST\Server\Controller\Role\$userService
$userService
Definition: Core/REST/Server/Controller/Role.php:44
eZ\Publish\Core\REST\Server\Controller\Role\updateRoleDraft
updateRoleDraft($roleId, Request $request)
Updates a role draft.
Definition: Core/REST/Server/Controller/Role.php:243
eZ\Publish\Core\REST\Server\Controller\Role\getLastAddedPolicy
getLastAddedPolicy($role)
Get the last added policy for $role.
Definition: Core/REST/Server/Controller/Role.php:461
eZ\Publish\Core\REST\Server\Controller\Role\listPoliciesForUser
listPoliciesForUser(Request $request)
Search all policies which are applied to a given user.
Definition: Core/REST/Server/Controller/Role.php:847
eZ\Publish\Core\REST\Server\Controller\Role\assignRoleToUser
assignRoleToUser($userId, Request $request)
Assigns role to user.
Definition: Core/REST/Server/Controller/Role.php:660
eZ\Publish\Core\REST\Server\Controller\Role\$roleService
$roleService
Definition: Core/REST/Server/Controller/Role.php:37
eZ\Publish\Core\REST\Server\Controller\Role\mapToUpdateStruct
mapToUpdateStruct(RoleCreateStruct $createStruct)
Maps a RoleCreateStruct to a RoleUpdateStruct.
Definition: Core/REST/Server/Controller/Role.php:866
eZ\Publish\Core\REST\Server\Controller\Role\publishRoleDraft
publishRoleDraft($roleId)
Publishes a role draft.
Definition: Core/REST/Server/Controller/Role.php:271
eZ\Publish\Core\REST\Server\Controller\Role\deleteRoleDraft
deleteRoleDraft($roleId)
Delete a role draft by ID.
Definition: Core/REST/Server/Controller/Role.php:314
eZ\Publish\Core\REST\Server\Controller\Role\updatePolicyByRoleDraft
updatePolicyByRoleDraft($roleId, $policyId, Request $request)
Updates a policy.
Definition: Core/REST/Server/Controller/Role.php:542
eZ\Publish\Core\REST\Server\Controller\Role\loadRole
loadRole($roleId)
Loads role.
Definition: Core/REST/Server/Controller/Role.php:190
eZ\Publish\Core\REST\Server\Controller\Role\updatePolicy
updatePolicy($roleId, $policyId, Request $request)
Updates a policy.
Definition: Core/REST/Server/Controller/Role.php:485
eZ\Publish\Core\REST\Server\Controller\Role\removePolicyByRoleDraft
removePolicyByRoleDraft($roleId, $policyId, Request $request)
Remove a policy from a role draft.
Definition: Core/REST/Server/Controller/Role.php:632
eZ\Publish\Core\REST\Server\Controller\Role\listRoles
listRoles(Request $request)
Loads list of roles.
Definition: Core/REST/Server/Controller/Role.php:159
eZ\Publish\Core\REST\Server\Controller\Role\updateRole
updateRole($roleId, Request $request)
Updates a role.
Definition: Core/REST/Server/Controller/Role.php:221
eZ\Publish\Core\REST\Server\Controller\Role\loadRoleAssignmentForUser
loadRoleAssignmentForUser($userId, $roleId, Request $request)
Returns a role assignment to the given user.
Definition: Core/REST/Server/Controller/Role.php:802
eZ\Publish\Core\REST\Server\Controller\Role\loadRoleAssignmentsForUser
loadRoleAssignmentsForUser($userId)
Loads role assignments for user.
Definition: Core/REST/Server/Controller/Role.php:765
eZ\Publish\Core\REST\Server\Controller\Role\deletePolicy
deletePolicy($roleId, $policyId, Request $request)
Delete a policy from role.
Definition: Core/REST/Server/Controller/Role.php:578
eZ\Publish\Core\REST\Server\Controller\Role\__construct
__construct(RoleService $roleService, UserService $userService, LocationService $locationService)
Construct controller.
Definition: Core/REST/Server/Controller/Role.php:60
eZ\Publish\Core\REST\Server\Controller\Role\loadRoleDraft
loadRoleDraft($roleId)
Loads a role draft.
Definition: Core/REST/Server/Controller/Role.php:202
eZ\Publish\Core\REST\Server\Controller\Role\unassignRoleFromUserGroup
unassignRoleFromUserGroup($groupPath, $roleId)
Un-assigns role from user group.
Definition: Core/REST/Server/Controller/Role.php:744
eZ\Publish\Core\REST\Server\Controller\Role\loadPolicies
loadPolicies($roleId, Request $request)
Loads the policies for the role.
Definition: Core/REST/Server/Controller/Role.php:330
eZ\Publish\Core\REST\Server\Controller\Role\createRoleDraft
createRoleDraft($roleId, Request $request)
Creates a new RoleDraft for an existing Role.
Definition: Core/REST/Server/Controller/Role.php:135
eZ\Publish\Core\REST\Server\Controller\Role\$locationService
$locationService
Definition: Core/REST/Server/Controller/Role.php:51
eZ\Publish\Core\REST\Server\Controller\Role\assignRoleToUserGroup
assignRoleToUserGroup($groupPath, Request $request)
Assigns role to user group.
Definition: Core/REST/Server/Controller/Role.php:690
eZ\Publish\Core\REST\Server\Controller\Role\createRole
createRole(Request $request)
Create new role.
Definition: Core/REST/Server/Controller/Role.php:77
eZ\Publish\Core\REST\Server\Controller\Role\addPolicy
addPolicy($roleId, Request $request)
Adds a policy to role.
Definition: Core/REST/Server/Controller/Role.php:384
eZ\Publish\Core\REST\Server\Controller\Role\deletePolicies
deletePolicies($roleId)
Deletes all policies from a role.
Definition: Core/REST/Server/Controller/Role.php:344
eZ\Publish\Core\REST\Server\Controller\Role\loadPolicy
loadPolicy($roleId, $policyId, Request $request)
Loads a policy.
Definition: Core/REST/Server/Controller/Role.php:365
eZ\Publish\Core\REST\Server\Exceptions\BadRequestException
Exception thrown if the request is not formatted correctly.
Definition: Exceptions/BadRequestException.php:15
eZ\Publish\Core\REST\Server\Values\CreatedPolicy
Struct representing a freshly created policy.
Definition: Values/CreatedPolicy.php:15
eZ\Publish\Core\REST\Server\Values\CreatedRole
Struct representing a freshly created Role.
Definition: Values/CreatedRole.php:15
eZ\Publish\Core\REST\Server\Values\NoContent
Definition: Values/NoContent.php:12
eZ\Publish\Core\REST\Server\Values\PolicyList
Policy list view model.
Definition: Server/Values/PolicyList.php:15
eZ\Publish\Core\REST\Server\Values\PublishedRole
Struct representing a published Role.
Definition: Values/PublishedRole.php:15
eZ\Publish\Core\REST\Server\Values\RestRole
REST Role, as received by /roles/<ID>.
Definition: RestRole.php:16
eZ\Publish\Core\REST\Server\Values\RestUserGroupRoleAssignment
RestUserGroupRoleAssignment view model.
Definition: Values/RestUserGroupRoleAssignment.php:16
eZ\Publish\Core\REST\Server\Values\RestUserRoleAssignment
RestUserRoleAssignment view model.
Definition: Values/RestUserRoleAssignment.php:16
eZ\Publish\Core\REST\Server\Values\RoleAssignmentList
RoleAssignment list view model.
Definition: Server/Values/RoleAssignmentList.php:15
eZ\Publish\Core\REST\Server\Values\RoleList
Role list view model.
Definition: Server/Values/RoleList.php:15
eZ\Publish\API\Repository\LocationService
Definition: API/Repository/LocationService.php:21
eZ\Publish\API\Repository\RoleService
This service provides methods for managing Roles and Policies.
Definition: API/Repository/RoleService.php:26
eZ\Publish\API\Repository\UserService
Definition: API/Repository/UserService.php:26
eZ\Publish\Core\REST\Common\Exceptions
Definition: Core/REST/Common/Exceptions/ForbiddenException.php:7
eZ\Publish\Core\REST\Server\Controller
Definition: BinaryContent.php:7
eZ\Publish\Core\REST\Server\Values
Definition: Core/REST/Server/Values/BookmarkList.php:9
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.