public function loadRelations(APIVersionInfo $versionInfo)
{
if ($versionInfo->status === APIVersionInfo::STATUS_PUBLISHED) {
$function = 'read';
} else {
$function = 'versionread';
}
if (!$this->repository->canUser('content', $function, $versionInfo)) {
throw new UnauthorizedException('content', $function);
}
$contentInfo = $versionInfo->getContentInfo();
$spiRelations = $this->persistenceHandler->contentHandler()->loadRelations($contentInfo->id, $versionInfo->versionNo);
/** @var $relations \eZ\Publish\API\Repository\Values\Content\Relation[] */
$relations = array();
foreach ($spiRelations as $spiRelation) {
$destinationContentInfo = $this->internalLoadContentInfo($spiRelation->destinationContentId);
if (!$this->repository->canUser('content', 'read', $destinationContentInfo)) {
continue;
}
$relations[] = $this->domainMapper->buildRelationDomainObject($spiRelation, $contentInfo, $destinationContentInfo);
}
return $relations;
}