public function setRelationshipTo(array &$target, ResourceObjectInterface $parent, RelationshipObjectInterface $relation, $value)
{
$parentId = $parent->getId();
$parentType = $parent->getType();
$name = $relation->getName();
$parentExists = isset($target[$parentType][$parentId]);
// parent object might be already fully parsed (with children) so
// - it won't exist in $target
// - it won't make any sense to parse it again (we'll got exactly the same result and it will be thrown away
// as duplicate relations/included resources are not allowed)
if ($parentExists === true) {
$isOk = isset($target[$parentType][$parentId][Document::KEYWORD_RELATIONSHIPS][$name]) === false;
$isOk ?: Exceptions::throwLogicException();
$representation = [];
if ($relation->isShowData() === true) {
$representation[Document::KEYWORD_LINKAGE_DATA] = $value;
}
$representation += $this->getRelationRepresentation($parent, $relation);
$target[$parentType][$parentId][Document::KEYWORD_RELATIONSHIPS][$name] = $representation;
}
}