Code Duplication    Length = 19-33 lines in 2 locations

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, which are readable by the current user.

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.