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

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