| @@ 1637-1657 (lines=21) @@ | ||
| 1634 | * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException |
|
| 1635 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException |
|
| 1636 | */ |
|
| 1637 | public function removeContentTypeTranslation(APIContentTypeDraft $contentTypeDraft, string $languageCode): APIContentTypeDraft |
|
| 1638 | { |
|
| 1639 | if (!$this->permissionResolver->canUser('class', 'update', $contentTypeDraft)) { |
|
| 1640 | throw new UnauthorizedException('ContentType', 'update'); |
|
| 1641 | } |
|
| 1642 | ||
| 1643 | $this->repository->beginTransaction(); |
|
| 1644 | try { |
|
| 1645 | $contentType = $this->contentTypeHandler->removeContentTypeTranslation( |
|
| 1646 | $contentTypeDraft->id, |
|
| 1647 | $languageCode |
|
| 1648 | ); |
|
| 1649 | ||
| 1650 | $this->repository->commit(); |
|
| 1651 | } catch (Exception $e) { |
|
| 1652 | $this->repository->rollback(); |
|
| 1653 | throw $e; |
|
| 1654 | } |
|
| 1655 | ||
| 1656 | return $this->contentTypeDomainMapper->buildContentTypeDraftDomainObject($contentType); |
|
| 1657 | } |
|
| 1658 | ||
| 1659 | public function deleteUserDrafts(int $userId): void |
|
| 1660 | { |
|
| @@ 237-253 (lines=17) @@ | ||
| 234 | * |
|
| 235 | * @param \eZ\Publish\API\Repository\Values\ObjectState\ObjectStateGroup $objectStateGroup |
|
| 236 | */ |
|
| 237 | public function deleteObjectStateGroup(APIObjectStateGroup $objectStateGroup) |
|
| 238 | { |
|
| 239 | if (!$this->permissionResolver->canUser('state', 'administrate', $objectStateGroup)) { |
|
| 240 | throw new UnauthorizedException('state', 'administrate'); |
|
| 241 | } |
|
| 242 | ||
| 243 | $loadedObjectStateGroup = $this->loadObjectStateGroup($objectStateGroup->id); |
|
| 244 | ||
| 245 | $this->repository->beginTransaction(); |
|
| 246 | try { |
|
| 247 | $this->objectStateHandler->deleteGroup($loadedObjectStateGroup->id); |
|
| 248 | $this->repository->commit(); |
|
| 249 | } catch (Exception $e) { |
|
| 250 | $this->repository->rollback(); |
|
| 251 | throw $e; |
|
| 252 | } |
|
| 253 | } |
|
| 254 | ||
| 255 | /** |
|
| 256 | * Creates a new object state in the given group. |
|
| @@ 427-443 (lines=17) @@ | ||
| 424 | * |
|
| 425 | * @param \eZ\Publish\API\Repository\Values\ObjectState\ObjectState $objectState |
|
| 426 | */ |
|
| 427 | public function deleteObjectState(APIObjectState $objectState) |
|
| 428 | { |
|
| 429 | if (!$this->permissionResolver->canUser('state', 'administrate', $objectState)) { |
|
| 430 | throw new UnauthorizedException('state', 'administrate'); |
|
| 431 | } |
|
| 432 | ||
| 433 | $loadedObjectState = $this->loadObjectState($objectState->id); |
|
| 434 | ||
| 435 | $this->repository->beginTransaction(); |
|
| 436 | try { |
|
| 437 | $this->objectStateHandler->delete($loadedObjectState->id); |
|
| 438 | $this->repository->commit(); |
|
| 439 | } catch (Exception $e) { |
|
| 440 | $this->repository->rollback(); |
|
| 441 | throw $e; |
|
| 442 | } |
|
| 443 | } |
|
| 444 | ||
| 445 | /** |
|
| 446 | * Sets the object-state of a state group to $state for the given content. |
|
| @@ 614-630 (lines=17) @@ | ||
| 611 | * |
|
| 612 | * @param \eZ\Publish\API\Repository\Values\User\Role $role |
|
| 613 | */ |
|
| 614 | public function deleteRole(APIRole $role) |
|
| 615 | { |
|
| 616 | if (!$this->permissionResolver->canUser('role', 'delete', $role)) { |
|
| 617 | throw new UnauthorizedException('role', 'delete'); |
|
| 618 | } |
|
| 619 | ||
| 620 | $loadedRole = $this->loadRole($role->id); |
|
| 621 | ||
| 622 | $this->repository->beginTransaction(); |
|
| 623 | try { |
|
| 624 | $this->userHandler->deleteRole($loadedRole->id); |
|
| 625 | $this->repository->commit(); |
|
| 626 | } catch (Exception $e) { |
|
| 627 | $this->repository->rollback(); |
|
| 628 | throw $e; |
|
| 629 | } |
|
| 630 | } |
|
| 631 | ||
| 632 | /** |
|
| 633 | * Assigns a role to the given user group. |
|
| @@ 735-751 (lines=17) @@ | ||
| 732 | * |
|
| 733 | * @param \eZ\Publish\API\Repository\Values\User\RoleAssignment $roleAssignment |
|
| 734 | */ |
|
| 735 | public function removeRoleAssignment(RoleAssignment $roleAssignment) |
|
| 736 | { |
|
| 737 | if ($this->permissionResolver->canUser('role', 'assign', $roleAssignment) !== true) { |
|
| 738 | throw new UnauthorizedException('role', 'assign'); |
|
| 739 | } |
|
| 740 | ||
| 741 | $spiRoleAssignment = $this->userHandler->loadRoleAssignment($roleAssignment->id); |
|
| 742 | ||
| 743 | $this->repository->beginTransaction(); |
|
| 744 | try { |
|
| 745 | $this->userHandler->removeRoleAssignment($spiRoleAssignment->id); |
|
| 746 | $this->repository->commit(); |
|
| 747 | } catch (Exception $e) { |
|
| 748 | $this->repository->rollback(); |
|
| 749 | throw $e; |
|
| 750 | } |
|
| 751 | } |
|
| 752 | ||
| 753 | /** |
|
| 754 | * Loads a role assignment for the given id. |
|