Code Duplication    Length = 19-33 lines in 2 locations

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

@@ 243-261 (lines=19) @@
240
     *
241
     * @param \eZ\Publish\API\Repository\Values\Content\TrashItem $trashItem
242
     */
243
    public function deleteTrashItem(APITrashItem $trashItem)
244
    {
245
        if ($this->repository->hasAccess('content', 'cleantrash') !== true) {
246
            throw new UnauthorizedException('content', 'cleantrash');
247
        }
248
249
        if (!is_numeric($trashItem->id)) {
250
            throw new InvalidArgumentValue('id', $trashItem->id, 'TrashItem');
251
        }
252
253
        $this->repository->beginTransaction();
254
        try {
255
            $this->persistenceHandler->trashHandler()->deleteTrashItem($trashItem->id);
256
            $this->repository->commit();
257
        } catch (Exception $e) {
258
            $this->repository->rollback();
259
            throw $e;
260
        }
261
    }
262
263
    /**
264
     * Returns a collection of Trashed locations contained in the trash, which are readable by the current user.

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

@@ 493-525 (lines=33) @@
490
     *
491
     * @param \eZ\Publish\API\Repository\Values\User\RoleDraft $roleDraft
492
     */
493
    public function publishRoleDraft(APIRoleDraft $roleDraft)
494
    {
495
        if ($this->repository->hasAccess('role', 'update') !== true) {
496
            throw new UnauthorizedException('role', 'update');
497
        }
498
499
        try {
500
            $loadedRoleDraft = $this->loadRoleDraft($roleDraft->id);
501
        } catch (APINotFoundException $e) {
502
            throw new BadStateException(
503
                '$roleDraft',
504
                'The role does not have a draft.',
505
                $e
506
            );
507
        }
508
509
        // TODO: Uncomment when role policy editing is done, see EZP-24711 & EZP-24713
510
        /*if (count($loadedRoleDraft->getPolicies()) === 0) {
511
            throw new InvalidArgumentException(
512
                "\$roleDraft",
513
                'The role draft should have at least one policy.'
514
            );
515
        }*/
516
517
        $this->repository->beginTransaction();
518
        try {
519
            $this->userHandler->publishRoleDraft($loadedRoleDraft->id);
520
            $this->repository->commit();
521
        } catch (Exception $e) {
522
            $this->repository->rollback();
523
            throw $e;
524
        }
525
    }
526
527
    /**
528
     * Updates the name of the role.