eZ\Publish\Core\Repository\ContentService::loadVersionInfoById PHP Method

loadVersionInfoById() public method

If no version number is given, the method returns the current version
public loadVersionInfoById ( mixed $contentId, integer $versionNo = null ) : eZ\Publish\API\Repository\Values\Content\VersionInfo
$contentId mixed
$versionNo integer the version number. If not given the current version is returned.
return eZ\Publish\API\Repository\Values\Content\VersionInfo
    public function loadVersionInfoById($contentId, $versionNo = null)
    {
        if ($versionNo === null) {
            $versionNo = $this->loadContentInfo($contentId)->currentVersionNo;
        }
        try {
            $spiVersionInfo = $this->persistenceHandler->contentHandler()->loadVersionInfo($contentId, $versionNo);
        } catch (APINotFoundException $e) {
            throw new NotFoundException('VersionInfo', array('contentId' => $contentId, 'versionNo' => $versionNo), $e);
        }
        $versionInfo = $this->domainMapper->buildVersionInfoDomainObject($spiVersionInfo);
        if ($versionInfo->status === APIVersionInfo::STATUS_PUBLISHED) {
            $function = 'read';
        } else {
            $function = 'versionread';
        }
        if (!$this->repository->canUser('content', $function, $versionInfo)) {
            throw new UnauthorizedException('content', $function, array('contentId' => $contentId));
        }
        return $versionInfo;
    }