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

loadContent() public method

Loads a content info, potentially with the current version embedded.
public loadContent ( mixed $contentId, Request $request ) : RestContent
$contentId mixed
$request Symfony\Component\HttpFoundation\Request
return eZ\Publish\Core\REST\Server\Values\RestContent
    public function loadContent($contentId, Request $request)
    {
        $contentInfo = $this->repository->getContentService()->loadContentInfo($contentId);
        $mainLocation = null;
        if (!empty($contentInfo->mainLocationId)) {
            $mainLocation = $this->repository->getLocationService()->loadLocation($contentInfo->mainLocationId);
        }
        $contentType = $this->repository->getContentTypeService()->loadContentType($contentInfo->contentTypeId);
        $contentVersion = null;
        $relations = null;
        if ($this->getMediaType($request) === 'application/vnd.ez.api.content') {
            $languages = null;
            if ($request->query->has('languages')) {
                $languages = explode(',', $request->query->get('languages'));
            }
            $contentVersion = $this->repository->getContentService()->loadContent($contentId, $languages);
            $relations = $this->repository->getContentService()->loadRelations($contentVersion->getVersionInfo());
        }
        $restContent = new Values\RestContent($contentInfo, $mainLocation, $contentVersion, $contentType, $relations, $request->getPathInfo());
        if ($contentInfo->mainLocationId === null) {
            return $restContent;
        }
        return new Values\CachedValue($restContent, array('locationId' => $contentInfo->mainLocationId));
    }