some bugfixes

This commit is contained in:
2023-01-11 14:05:45 +01:00
parent dee9d8c34e
commit 4c51403daa
2 changed files with 27 additions and 0 deletions

View File

@@ -94,6 +94,14 @@ abstract class DatabaseEntity implements ArrayAccess, JsonSerializable {
} else if ($value instanceof DatabaseEntity) {
$subPropertyNames = $propertyNames[$propertyName] ?? null;
$value = $value->jsonSerialize($subPropertyNames);
} else if (is_array($value)) {
$subPropertyNames = $propertyNames[$propertyName] ?? null;
$value = array_map(function ($item) use ($subPropertyNames) {
if ($item instanceof DatabaseEntity) {
$item = $item->jsonSerialize($subPropertyNames);
}
return $item;
}, $value);
}
$jsonArray[$property->getName()] = $value;