| @@ 522-554 (lines=33) @@ | ||
| 519 | * |
|
| 520 | * @param \eZ\Publish\API\Repository\Values\User\RoleDraft $roleDraft |
|
| 521 | */ |
|
| 522 | public function publishRoleDraft(APIRoleDraft $roleDraft) |
|
| 523 | { |
|
| 524 | if ($this->repository->hasAccess('role', 'update') !== true) { |
|
| 525 | throw new UnauthorizedException('role', 'update'); |
|
| 526 | } |
|
| 527 | ||
| 528 | try { |
|
| 529 | $loadedRoleDraft = $this->loadRoleDraft($roleDraft->id); |
|
| 530 | } catch (APINotFoundException $e) { |
|
| 531 | throw new BadStateException( |
|
| 532 | '$roleDraft', |
|
| 533 | 'The role does not have a draft.', |
|
| 534 | $e |
|
| 535 | ); |
|
| 536 | } |
|
| 537 | ||
| 538 | // TODO: Uncomment when role policy editing is done, see EZP-24711 & EZP-24713 |
|
| 539 | /*if (count($loadedRoleDraft->getPolicies()) === 0) { |
|
| 540 | throw new InvalidArgumentException( |
|
| 541 | "\$roleDraft", |
|
| 542 | 'The role draft should have at least one policy.' |
|
| 543 | ); |
|
| 544 | }*/ |
|
| 545 | ||
| 546 | $this->repository->beginTransaction(); |
|
| 547 | try { |
|
| 548 | $this->userHandler->publishRoleDraft($loadedRoleDraft->id); |
|
| 549 | $this->repository->commit(); |
|
| 550 | } catch (Exception $e) { |
|
| 551 | $this->repository->rollback(); |
|
| 552 | throw $e; |
|
| 553 | } |
|
| 554 | } |
|
| 555 | ||
| 556 | /** |
|
| 557 | * Updates the name of the role. |
|
| @@ 235-253 (lines=19) @@ | ||
| 232 | * |
|
| 233 | * @param \eZ\Publish\API\Repository\Values\Content\TrashItem $trashItem |
|
| 234 | */ |
|
| 235 | public function deleteTrashItem(APITrashItem $trashItem) |
|
| 236 | { |
|
| 237 | if ($this->repository->hasAccess('content', 'cleantrash') !== true) { |
|
| 238 | throw new UnauthorizedException('content', 'cleantrash'); |
|
| 239 | } |
|
| 240 | ||
| 241 | if (!is_numeric($trashItem->id)) { |
|
| 242 | throw new InvalidArgumentValue('id', $trashItem->id, 'TrashItem'); |
|
| 243 | } |
|
| 244 | ||
| 245 | $this->repository->beginTransaction(); |
|
| 246 | try { |
|
| 247 | $this->persistenceHandler->trashHandler()->deleteTrashItem($trashItem->id); |
|
| 248 | $this->repository->commit(); |
|
| 249 | } catch (Exception $e) { |
|
| 250 | $this->repository->rollback(); |
|
| 251 | throw $e; |
|
| 252 | } |
|
| 253 | } |
|
| 254 | ||
| 255 | /** |
|
| 256 | * Returns a collection of Trashed locations contained in the trash. |
|