|
@@ 407-420 (lines=14) @@
|
| 404 |
|
* |
| 405 |
|
* @return APIRoleDraft if the authenticated user is not allowed to remove a policy |
| 406 |
|
*/ |
| 407 |
|
public function removePolicyByRoleDraft(APIRoleDraft $roleDraft, PolicyDraft $policyDraft) |
| 408 |
|
{ |
| 409 |
|
if ($this->repository->hasAccess('role', 'update') !== true) { |
| 410 |
|
throw new UnauthorizedException('role', 'update'); |
| 411 |
|
} |
| 412 |
|
|
| 413 |
|
if ($policyDraft->roleId != $roleDraft->id) { |
| 414 |
|
throw new InvalidArgumentException('$policy', 'Policy does not belong to the given role'); |
| 415 |
|
} |
| 416 |
|
|
| 417 |
|
$this->internalDeletePolicy($policyDraft); |
| 418 |
|
|
| 419 |
|
return $this->loadRoleDraft($roleDraft->id); |
| 420 |
|
} |
| 421 |
|
|
| 422 |
|
/** |
| 423 |
|
* Updates the limitations of a policy. The module and function cannot be changed and |
|
@@ 691-704 (lines=14) @@
|
| 688 |
|
* |
| 689 |
|
* @return \eZ\Publish\API\Repository\Values\User\Role the updated role |
| 690 |
|
*/ |
| 691 |
|
public function removePolicy(APIRole $role, APIPolicy $policy) |
| 692 |
|
{ |
| 693 |
|
if ($this->repository->hasAccess('role', 'update') !== true) { |
| 694 |
|
throw new UnauthorizedException('role', 'update'); |
| 695 |
|
} |
| 696 |
|
|
| 697 |
|
if ($policy->roleId != $role->id) { |
| 698 |
|
throw new InvalidArgumentException('$policy', 'Policy does not belong to the given role'); |
| 699 |
|
} |
| 700 |
|
|
| 701 |
|
$this->internalDeletePolicy($policy); |
| 702 |
|
|
| 703 |
|
return $this->loadRole($role->id); |
| 704 |
|
} |
| 705 |
|
|
| 706 |
|
/** |
| 707 |
|
* Deletes a policy. |