| @@ 391-414 (lines=24) @@ | ||
| 388 | * @param \eZ\Publish\API\Repository\Values\ObjectState\ObjectState $objectState |
|
| 389 | * @param int $priority |
|
| 390 | */ |
|
| 391 | public function setPriorityOfObjectState(APIObjectState $objectState, $priority) |
|
| 392 | { |
|
| 393 | if (!is_int($priority)) { |
|
| 394 | throw new InvalidArgumentValue('priority', $priority); |
|
| 395 | } |
|
| 396 | ||
| 397 | if (!$this->repository->canUser('state', 'administrate', $objectState)) { |
|
| 398 | throw new UnauthorizedException('state', 'administrate'); |
|
| 399 | } |
|
| 400 | ||
| 401 | $loadedObjectState = $this->loadObjectState($objectState->id); |
|
| 402 | ||
| 403 | $this->repository->beginTransaction(); |
|
| 404 | try { |
|
| 405 | $this->objectStateHandler->setPriority( |
|
| 406 | $loadedObjectState->id, |
|
| 407 | $priority |
|
| 408 | ); |
|
| 409 | $this->repository->commit(); |
|
| 410 | } catch (Exception $e) { |
|
| 411 | $this->repository->rollback(); |
|
| 412 | throw $e; |
|
| 413 | } |
|
| 414 | } |
|
| 415 | ||
| 416 | /** |
|
| 417 | * Deletes a object state. The state of the content objects is reset to the |
|
| @@ 267-287 (lines=21) @@ | ||
| 264 | * |
|
| 265 | * @return \eZ\Publish\API\Repository\Values\Content\Trash\TrashItemDeleteResult |
|
| 266 | */ |
|
| 267 | public function deleteTrashItem(APITrashItem $trashItem) |
|
| 268 | { |
|
| 269 | if (!$this->repository->canUser('content', 'cleantrash', $trashItem->getContentInfo())) { |
|
| 270 | throw new UnauthorizedException('content', 'cleantrash'); |
|
| 271 | } |
|
| 272 | ||
| 273 | if (!is_numeric($trashItem->id)) { |
|
| 274 | throw new InvalidArgumentValue('id', $trashItem->id, 'TrashItem'); |
|
| 275 | } |
|
| 276 | ||
| 277 | $this->repository->beginTransaction(); |
|
| 278 | try { |
|
| 279 | $trashItemDeleteResult = $this->persistenceHandler->trashHandler()->deleteTrashItem($trashItem->id); |
|
| 280 | $this->repository->commit(); |
|
| 281 | ||
| 282 | return $trashItemDeleteResult; |
|
| 283 | } catch (Exception $e) { |
|
| 284 | $this->repository->rollback(); |
|
| 285 | throw $e; |
|
| 286 | } |
|
| 287 | } |
|
| 288 | ||
| 289 | /** |
|
| 290 | * Returns a collection of Trashed locations contained in the trash, which are readable by the current user. |
|