Code Duplication    Length = 19-24 lines in 2 locations

eZ/Publish/Core/REST/Server/Controller/Content.php 2 locations

@@ 430-448 (lines=19) @@
427
     *
428
     * @return \eZ\Publish\Core\REST\Server\Values\CreatedVersion
429
     */
430
    public function createDraftFromVersion($contentId, $versionNumber)
431
    {
432
        $contentInfo = $this->repository->getContentService()->loadContentInfo($contentId);
433
        $contentType = $this->repository->getContentTypeService()->loadContentType($contentInfo->contentTypeId);
434
        $contentDraft = $this->repository->getContentService()->createContentDraft(
435
            $contentInfo,
436
            $this->repository->getContentService()->loadVersionInfo($contentInfo, $versionNumber)
437
        );
438
439
        return new Values\CreatedVersion(
440
            array(
441
                'version' => new Values\Version(
442
                    $contentDraft,
443
                    $contentType,
444
                    $this->repository->getContentService()->loadRelations($contentDraft->getVersionInfo())
445
                ),
446
            )
447
        );
448
    }
449
450
    /**
451
     * The system creates a new draft version as a copy from the current version.
@@ 459-482 (lines=24) @@
456
     *
457
     * @return \eZ\Publish\Core\REST\Server\Values\CreatedVersion
458
     */
459
    public function createDraftFromCurrentVersion($contentId)
460
    {
461
        $contentInfo = $this->repository->getContentService()->loadContentInfo($contentId);
462
        $contentType = $this->repository->getContentTypeService()->loadContentType($contentInfo->contentTypeId);
463
        $versionInfo = $this->repository->getContentService()->loadVersionInfo(
464
            $contentInfo
465
        );
466
467
        if ($versionInfo->isDraft()) {
468
            throw new ForbiddenException('Current version is already in status DRAFT');
469
        }
470
471
        $contentDraft = $this->repository->getContentService()->createContentDraft($contentInfo);
472
473
        return new Values\CreatedVersion(
474
            array(
475
                'version' => new Values\Version(
476
                    $contentDraft,
477
                    $contentType,
478
                    $this->repository->getContentService()->loadRelations($contentDraft->getVersionInfo())
479
                ),
480
            )
481
        );
482
    }
483
484
    /**
485
     * A specific draft is updated.