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

loadVersionRelation() public method

Loads a relation for the given content object and version.
public loadVersionRelation ( mixed $contentId, integer $versionNumber, mixed $relationId, Request $request ) : RestRelation
$contentId mixed
$versionNumber integer
$relationId mixed
$request Symfony\Component\HttpFoundation\Request
return eZ\Publish\Core\REST\Server\Values\RestRelation
    public function loadVersionRelation($contentId, $versionNumber, $relationId, Request $request)
    {
        $contentInfo = $this->repository->getContentService()->loadContentInfo($contentId);
        $relationList = $this->repository->getContentService()->loadRelations($this->repository->getContentService()->loadVersionInfo($contentInfo, $versionNumber));
        foreach ($relationList as $relation) {
            if ($relation->id == $relationId) {
                $relation = new Values\RestRelation($relation, $contentId, $versionNumber);
                if ($contentInfo->mainLocationId === null) {
                    return $relation;
                }
                return new Values\CachedValue($relation, array('locationId' => $contentInfo->mainLocationId));
            }
        }
        throw new Exceptions\NotFoundException("Relation not found: '{$request->getPathInfo()}'.");
    }