|
@@ 635-654 (lines=20) @@
|
| 632 |
|
* @param \eZ\Publish\API\Repository\Values\User\UserGroup $userGroup |
| 633 |
|
* @param \eZ\Publish\API\Repository\Values\User\Limitation\RoleLimitation $roleLimitation an optional role limitation (which is either a subtree limitation or section limitation) |
| 634 |
|
*/ |
| 635 |
|
public function assignRoleToUserGroup(APIRole $role, UserGroup $userGroup, RoleLimitation $roleLimitation = null) |
| 636 |
|
{ |
| 637 |
|
$roleAssignment = new RoleAssignment( |
| 638 |
|
array( |
| 639 |
|
'role' => $role, |
| 640 |
|
'limitation' => $roleLimitation, |
| 641 |
|
) |
| 642 |
|
); |
| 643 |
|
|
| 644 |
|
$inputMessage = $this->outputVisitor->visit($roleAssignment); |
| 645 |
|
$inputMessage->headers['Accept'] = $this->outputVisitor->getMediaType('RoleAssignmentList'); |
| 646 |
|
|
| 647 |
|
$result = $this->client->request( |
| 648 |
|
'POST', |
| 649 |
|
$this->requestParser->generate('groupRoleAssignments', array('group' => $userGroup->id)), |
| 650 |
|
$inputMessage |
| 651 |
|
); |
| 652 |
|
|
| 653 |
|
$this->inputDispatcher->parse($result); |
| 654 |
|
} |
| 655 |
|
|
| 656 |
|
/** |
| 657 |
|
* removes a role from the given user group. |
|
@@ 702-721 (lines=20) @@
|
| 699 |
|
* @param \eZ\Publish\API\Repository\Values\User\User $user |
| 700 |
|
* @param \eZ\Publish\API\Repository\Values\User\Limitation\RoleLimitation $roleLimitation an optional role limitation (which is either a subtree limitation or section limitation) |
| 701 |
|
*/ |
| 702 |
|
public function assignRoleToUser(APIRole $role, User $user, RoleLimitation $roleLimitation = null) |
| 703 |
|
{ |
| 704 |
|
$roleAssignment = new RoleAssignment( |
| 705 |
|
array( |
| 706 |
|
'role' => $role, |
| 707 |
|
'limitation' => $roleLimitation, |
| 708 |
|
) |
| 709 |
|
); |
| 710 |
|
|
| 711 |
|
$inputMessage = $this->outputVisitor->visit($roleAssignment); |
| 712 |
|
$inputMessage->headers['Accept'] = $this->outputVisitor->getMediaType('RoleAssignmentList'); |
| 713 |
|
|
| 714 |
|
$result = $this->client->request( |
| 715 |
|
'POST', |
| 716 |
|
$this->requestParser->generate('userRoleAssignments', array('user' => $user->id)), |
| 717 |
|
$inputMessage |
| 718 |
|
); |
| 719 |
|
|
| 720 |
|
$this->inputDispatcher->parse($result); |
| 721 |
|
} |
| 722 |
|
|
| 723 |
|
/** |
| 724 |
|
* removes a role from the given user. |