Skip to content

Commit

Permalink
Merge pull request #1645 from ConductionNL/fix/GW-1665/inversedBy-and…
Browse files Browse the repository at this point in the history
…-format-json

Fix inversedBy in combination with format json
  • Loading branch information
bbrands02 committed May 2, 2024
2 parents 1462da3 + f6ccf84 commit 1ca1d6e
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions api/src/Entity/ObjectEntity.php
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 1ca1d6e

Please sign in to comment.