Code Duplication    Length = 21-24 lines in 2 locations

eZ/Publish/Core/Repository/ObjectStateService.php 1 location

@@ 385-408 (lines=24) @@
382
     * @param \eZ\Publish\API\Repository\Values\ObjectState\ObjectState $objectState
383
     * @param int $priority
384
     */
385
    public function setPriorityOfObjectState(APIObjectState $objectState, $priority)
386
    {
387
        if (!is_int($priority)) {
388
            throw new InvalidArgumentValue('priority', $priority);
389
        }
390
391
        if (!$this->repository->canUser('state', 'administrate', $objectState)) {
392
            throw new UnauthorizedException('state', 'administrate');
393
        }
394
395
        $loadedObjectState = $this->loadObjectState($objectState->id);
396
397
        $this->repository->beginTransaction();
398
        try {
399
            $this->objectStateHandler->setPriority(
400
                $loadedObjectState->id,
401
                $priority
402
            );
403
            $this->repository->commit();
404
        } catch (Exception $e) {
405
            $this->repository->rollback();
406
            throw $e;
407
        }
408
    }
409
410
    /**
411
     * Deletes a object state. The state of the content objects is reset to the

eZ/Publish/Core/Repository/TrashService.php 1 location

@@ 256-276 (lines=21) @@
253
     *
254
     * @return \eZ\Publish\API\Repository\Values\Content\Trash\TrashItemDeleteResult
255
     */
256
    public function deleteTrashItem(APITrashItem $trashItem)
257
    {
258
        if (!$this->repository->canUser('content', 'cleantrash', $trashItem->getContentInfo())) {
259
            throw new UnauthorizedException('content', 'cleantrash');
260
        }
261
262
        if (!is_numeric($trashItem->id)) {
263
            throw new InvalidArgumentValue('id', $trashItem->id, 'TrashItem');
264
        }
265
266
        $this->repository->beginTransaction();
267
        try {
268
            $trashItemDeleteResult = $this->persistenceHandler->trashHandler()->deleteTrashItem($trashItem->id);
269
            $this->repository->commit();
270
271
            return $trashItemDeleteResult;
272
        } catch (Exception $e) {
273
            $this->repository->rollback();
274
            throw $e;
275
        }
276
    }
277
278
    /**
279
     * Returns a collection of Trashed locations contained in the trash, which are readable by the current user.