diff --git a/api/src/Entity/ObjectEntity.php b/api/src/Entity/ObjectEntity.php index 49b583411..4a8b59f2c 100644 --- a/api/src/Entity/ObjectEntity.php +++ b/api/src/Entity/ObjectEntity.php @@ -1213,7 +1213,21 @@ public function toArray(array $configuration = []): array // If we don't set the full object then we want to set self else { // $array[$attribute->getName()] = $object->getSelf() ?? ('/api' . ($object->getEntity()->getRoute() ?? $object->getEntity()->getName()) . '/' . $object->getId()); - $array[$attribute->getName()] = $object->getSelf(); + switch ($attribute->getFormat()) { + case 'uuid': + $array[$attribute->getName()] = $object->getId()->toString(); + break; + case 'url': + $array[$attribute->getName()] = $object->getUri(); + break; + case 'json': + $array[$attribute->getName()] = $objectToArray; + break; + case 'iri': + default: + $array[$attribute->getName()] = $object->getSelf(); + break; + } } } } elseif (count($valueObject->getObjects()) === 0) { @@ -1261,8 +1275,22 @@ public function toArray(array $configuration = []): array } // If we don't set the full object then we want to set self else { - // $array[$attribute->getName()][] = $object->getSelf() ?? ('/api' . ($object->getEntity()->getRoute() ?? $object->getEntity()->getName()) . '/' . $object->getId()); - $array[$attribute->getName()][] = $object->getSelf(); + switch ($attribute->getFormat()) { + case 'uuid': + $array[$attribute->getName()][] = $object->getId()->toString(); + break; + case 'url': + case 'uri': + $array[$attribute->getName()][] = $object->getUri(); + break; + case 'json': + $array[$attribute->getName()][] = $objectToArray; + break; + case 'iri': + default: + $array[$attribute->getName()][] = $object->getSelf(); + break; + } } } }