Code Duplication    Length = 19-33 lines in 2 locations

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

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