|
@@ 433-446 (lines=14) @@
|
| 430 |
|
* |
| 431 |
|
* @return APIRoleDraft if the authenticated user is not allowed to remove a policy |
| 432 |
|
*/ |
| 433 |
|
public function removePolicyByRoleDraft(APIRoleDraft $roleDraft, PolicyDraft $policyDraft) |
| 434 |
|
{ |
| 435 |
|
if ($this->repository->hasAccess('role', 'update') !== true) { |
| 436 |
|
throw new UnauthorizedException('role', 'update'); |
| 437 |
|
} |
| 438 |
|
|
| 439 |
|
if ($policyDraft->roleId != $roleDraft->id) { |
| 440 |
|
throw new InvalidArgumentException('$policy', 'Policy does not belong to the given role'); |
| 441 |
|
} |
| 442 |
|
|
| 443 |
|
$this->internalDeletePolicy($policyDraft); |
| 444 |
|
|
| 445 |
|
return $this->loadRoleDraft($roleDraft->id); |
| 446 |
|
} |
| 447 |
|
|
| 448 |
|
/** |
| 449 |
|
* Updates the limitations of a policy. The module and function cannot be changed and |
|
@@ 717-730 (lines=14) @@
|
| 714 |
|
* |
| 715 |
|
* @return \eZ\Publish\API\Repository\Values\User\Role the updated role |
| 716 |
|
*/ |
| 717 |
|
public function removePolicy(APIRole $role, APIPolicy $policy) |
| 718 |
|
{ |
| 719 |
|
if ($this->repository->hasAccess('role', 'update') !== true) { |
| 720 |
|
throw new UnauthorizedException('role', 'update'); |
| 721 |
|
} |
| 722 |
|
|
| 723 |
|
if ($policy->roleId != $role->id) { |
| 724 |
|
throw new InvalidArgumentException('$policy', 'Policy does not belong to the given role'); |
| 725 |
|
} |
| 726 |
|
|
| 727 |
|
$this->internalDeletePolicy($policy); |
| 728 |
|
|
| 729 |
|
return $this->loadRole($role->id); |
| 730 |
|
} |
| 731 |
|
|
| 732 |
|
/** |
| 733 |
|
* Deletes a policy. |