diff --git a/api/src/Entity/ObjectEntity.php b/api/src/Entity/ObjectEntity.php index f2a300666..878a0308a 100644 --- a/api/src/Entity/ObjectEntity.php +++ b/api/src/Entity/ObjectEntity.php @@ -1237,8 +1237,16 @@ public function toArray(array $configuration = []): array $config['renderedObjects'][] = $object; if ($attribute->getObject()->getMaxDepth() + $config['level'] < $config['maxDepth']) { $config['maxDepth'] = $attribute->getObject()->getMaxDepth() + $config['level']; + if ($attribute->getInversedBy() !== null) { + $array[$attribute->getName()] = $object->toArray($config); + } + } elseif ($attribute->getInversedBy() !== null) { + $array[$attribute->getName()] = $object->getSelf(); + } + + if ($attribute->getInversedBy() === null) { + $array[$attribute->getName()] = $object->toArray($config); } - $array[$attribute->getName()] = $object->toArray($config); break; case 'iri': default: @@ -1313,8 +1321,16 @@ public function toArray(array $configuration = []): array $config['renderedObjects'][] = $object; if ($attribute->getObject()->getMaxDepth() + $config['level'] < $config['maxDepth']) { $config['maxDepth'] = $attribute->getObject()->getMaxDepth() + $config['level']; + if ($attribute->getInversedBy() !== null) { + $array[$attribute->getName()] = $object->toArray($config); + } + } elseif ($attribute->getInversedBy() !== null) { + $array[$attribute->getName()] = $object->getSelf(); + } + + if ($attribute->getInversedBy() === null) { + $array[$attribute->getName()] = $object->toArray($config); } - $array[$attribute->getName()][] = $object->toArray($config); break; case 'iri': default: