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

@@ 548-580 (lines=33) @@
545
     *
546
     * @param \eZ\Publish\API\Repository\Values\User\RoleDraft $roleDraft
547
     */
548
    public function publishRoleDraft(APIRoleDraft $roleDraft)
549
    {
550
        if ($this->repository->hasAccess('role', 'update') !== true) {
551
            throw new UnauthorizedException('role', 'update');
552
        }
553
554
        try {
555
            $loadedRoleDraft = $this->loadRoleDraft($roleDraft->id);
556
        } catch (APINotFoundException $e) {
557
            throw new BadStateException(
558
                '$roleDraft',
559
                'The role does not have a draft.',
560
                $e
561
            );
562
        }
563
564
        // TODO: Uncomment when role policy editing is done, see EZP-24711 & EZP-24713
565
        /*if (count($loadedRoleDraft->getPolicies()) === 0) {
566
            throw new InvalidArgumentException(
567
                "\$roleDraft",
568
                'The role draft should have at least one policy.'
569
            );
570
        }*/
571
572
        $this->repository->beginTransaction();
573
        try {
574
            $this->userHandler->publishRoleDraft($loadedRoleDraft->id);
575
            $this->repository->commit();
576
        } catch (Exception $e) {
577
            $this->repository->rollback();
578
            throw $e;
579
        }
580
    }
581
582
    /**
583
     * Updates the name of the role.