Code Duplication    Length = 19-24 lines in 2 locations

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

@@ 396-414 (lines=19) @@
393
     *
394
     * @return \eZ\Publish\Core\REST\Server\Values\CreatedVersion
395
     */
396
    public function createDraftFromVersion($contentId, $versionNumber)
397
    {
398
        $contentInfo = $this->repository->getContentService()->loadContentInfo($contentId);
399
        $contentType = $this->repository->getContentTypeService()->loadContentType($contentInfo->contentTypeId);
400
        $contentDraft = $this->repository->getContentService()->createContentDraft(
401
            $contentInfo,
402
            $this->repository->getContentService()->loadVersionInfo($contentInfo, $versionNumber)
403
        );
404
405
        return new Values\CreatedVersion(
406
            array(
407
                'version' => new Values\Version(
408
                    $contentDraft,
409
                    $contentType,
410
                    $this->repository->getContentService()->loadRelations($contentDraft->getVersionInfo())
411
                ),
412
            )
413
        );
414
    }
415
416
    /**
417
     * The system creates a new draft version as a copy from the current version.
@@ 425-448 (lines=24) @@
422
     *
423
     * @return \eZ\Publish\Core\REST\Server\Values\CreatedVersion
424
     */
425
    public function createDraftFromCurrentVersion($contentId)
426
    {
427
        $contentInfo = $this->repository->getContentService()->loadContentInfo($contentId);
428
        $contentType = $this->repository->getContentTypeService()->loadContentType($contentInfo->contentTypeId);
429
        $versionInfo = $this->repository->getContentService()->loadVersionInfo(
430
            $contentInfo
431
        );
432
433
        if ($versionInfo->isDraft()) {
434
            throw new ForbiddenException('Current version is already in status DRAFT');
435
        }
436
437
        $contentDraft = $this->repository->getContentService()->createContentDraft($contentInfo);
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
     * A specific draft is updated.