/** * Removes the given role assignment. * * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the authenticated user is not allowed to remove a role assignment * * @param \eZ\Publish\API\Repository\Values\User\RoleAssignment $roleAssignment */ public function removeRoleAssignment(RoleAssignment $roleAssignment) { if ($this->repository->canUser('role', 'assign', $roleAssignment) !== true) { throw new UnauthorizedException('role', 'assign'); } $spiRoleAssignment = $this->userHandler->loadRoleAssignment($roleAssignment->id); $this->repository->beginTransaction(); try { $this->userHandler->removeRoleAssignment($spiRoleAssignment->id); $this->repository->commit(); } catch (Exception $e) { $this->repository->rollback(); throw $e; } }