eZ\Publish\Core\REST\Server\Controller\Content::createDraftFromCurrentVersion PHP Method

createDraftFromCurrentVersion() public method

The system creates a new draft version as a copy from the current version.
public createDraftFromCurrentVersion ( mixed $contentId ) : CreatedVersion
$contentId mixed
return eZ\Publish\Core\REST\Server\Values\CreatedVersion
    public function createDraftFromCurrentVersion($contentId)
    {
        $contentInfo = $this->repository->getContentService()->loadContentInfo($contentId);
        $contentType = $this->repository->getContentTypeService()->loadContentType($contentInfo->contentTypeId);
        $versionInfo = $this->repository->getContentService()->loadVersionInfo($contentInfo);
        if ($versionInfo->status === VersionInfo::STATUS_DRAFT) {
            throw new ForbiddenException('Current version is already in status DRAFT');
        }
        $contentDraft = $this->repository->getContentService()->createContentDraft($contentInfo);
        return new Values\CreatedVersion(array('version' => new Values\Version($contentDraft, $contentType, $this->repository->getContentService()->loadRelations($contentDraft->getVersionInfo()))));
    }