Code Duplication    Length = 19-33 lines in 2 locations

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.

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

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