Code Duplication    Length = 19-33 lines in 2 locations

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

@@ 520-552 (lines=33) @@
517
     *
518
     * @param \eZ\Publish\API\Repository\Values\User\RoleDraft $roleDraft
519
     */
520
    public function publishRoleDraft(APIRoleDraft $roleDraft)
521
    {
522
        if ($this->repository->hasAccess('role', 'update') !== true) {
523
            throw new UnauthorizedException('role', 'update');
524
        }
525
526
        try {
527
            $loadedRoleDraft = $this->loadRoleDraft($roleDraft->id);
528
        } catch (APINotFoundException $e) {
529
            throw new BadStateException(
530
                '$roleDraft',
531
                'The role does not have a draft.',
532
                $e
533
            );
534
        }
535
536
        // TODO: Uncomment when role policy editing is done, see EZP-24711 & EZP-24713
537
        /*if (count($loadedRoleDraft->getPolicies()) === 0) {
538
            throw new InvalidArgumentException(
539
                "\$roleDraft",
540
                'The role draft should have at least one policy.'
541
            );
542
        }*/
543
544
        $this->repository->beginTransaction();
545
        try {
546
            $this->userHandler->publishRoleDraft($loadedRoleDraft->id);
547
            $this->repository->commit();
548
        } catch (Exception $e) {
549
            $this->repository->rollback();
550
            throw $e;
551
        }
552
    }
553
554
    /**
555
     * Updates the name of the role.

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.