Code Duplication    Length = 19-24 lines in 2 locations

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

@@ 407-425 (lines=19) @@
404
     *
405
     * @return \eZ\Publish\Core\REST\Server\Values\CreatedVersion
406
     */
407
    public function createDraftFromVersion($contentId, $versionNumber)
408
    {
409
        $contentInfo = $this->repository->getContentService()->loadContentInfo($contentId);
410
        $contentType = $this->repository->getContentTypeService()->loadContentType($contentInfo->contentTypeId);
411
        $contentDraft = $this->repository->getContentService()->createContentDraft(
412
            $contentInfo,
413
            $this->repository->getContentService()->loadVersionInfo($contentInfo, $versionNumber)
414
        );
415
416
        return new Values\CreatedVersion(
417
            array(
418
                'version' => new Values\Version(
419
                    $contentDraft,
420
                    $contentType,
421
                    $this->repository->getContentService()->loadRelations($contentDraft->getVersionInfo())
422
                ),
423
            )
424
        );
425
    }
426
427
    /**
428
     * The system creates a new draft version as a copy from the current version.
@@ 436-459 (lines=24) @@
433
     *
434
     * @return \eZ\Publish\Core\REST\Server\Values\CreatedVersion
435
     */
436
    public function createDraftFromCurrentVersion($contentId)
437
    {
438
        $contentInfo = $this->repository->getContentService()->loadContentInfo($contentId);
439
        $contentType = $this->repository->getContentTypeService()->loadContentType($contentInfo->contentTypeId);
440
        $versionInfo = $this->repository->getContentService()->loadVersionInfo(
441
            $contentInfo
442
        );
443
444
        if ($versionInfo->isDraft()) {
445
            throw new ForbiddenException('Current version is already in status DRAFT');
446
        }
447
448
        $contentDraft = $this->repository->getContentService()->createContentDraft($contentInfo);
449
450
        return new Values\CreatedVersion(
451
            array(
452
                'version' => new Values\Version(
453
                    $contentDraft,
454
                    $contentType,
455
                    $this->repository->getContentService()->loadRelations($contentDraft->getVersionInfo())
456
                ),
457
            )
458
        );
459
    }
460
461
    /**
462
     * A specific draft is updated.