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

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