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

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