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

loadContentInVersion() public method

Loads a specific version of a given content object.
public loadContentInVersion ( mixed $contentId, integer $versionNumber, Request $request ) : Version
$contentId mixed
$versionNumber integer
$request Symfony\Component\HttpFoundation\Request
return eZ\Publish\Core\REST\Server\Values\Version
    public function loadContentInVersion($contentId, $versionNumber, Request $request)
    {
        $languages = null;
        if ($request->query->has('languages')) {
            $languages = explode(',', $request->query->get('languages'));
        }
        $content = $this->repository->getContentService()->loadContent($contentId, $languages, $versionNumber);
        $contentType = $this->repository->getContentTypeService()->loadContentType($content->getVersionInfo()->getContentInfo()->contentTypeId);
        $versionValue = new Values\Version($content, $contentType, $this->repository->getContentService()->loadRelations($content->getVersionInfo()), $request->getPathInfo());
        if ($content->contentInfo->mainLocationId === null || $content->versionInfo->status === VersionInfo::STATUS_DRAFT) {
            return $versionValue;
        }
        return new Values\CachedValue($versionValue, array('locationId' => $content->contentInfo->mainLocationId));
    }