Closed bogdandubyk closed 3 years ago
so I'm inserting dto like (it's a dump of dto):
SomeDto {#678
+id: 1
+name: "Liza Kessler"
+secondDto: SeconfDto {#709
+id: 1
+name: "Conroy-Wisoky"
}
+otherDtos: array:1 [
0 => ThirdDto {#705
+id: 1
+name: "Wiegand-Jerde"
}
1 => ThirdDto {#705
+id: 2
+name: "Conroy-Wisoky"
}
]
}
but getting back it in a format like :
SomeDto {#678
+id: 1
+name: "Liza Kessler"
+secondDto: SeconfDto {#709
+id: 1
+name: "Conroy-Wisoky"
}
+otherDtos: array:1 [
0 => array:2 [
+id: 1
+name: "Wiegand-Jerde"
]
1 => array:2
+id: 2
+name: "Conroy-Wisoky"
]
]
}
looks like it's a Symfony serializer issue.. BTW I'll leave this open for a some time, maybe I'll get some help,
I was right, it serializer issue, I fix it by adding
public function addOtherDtos(ThirdDto $dto) {
$this->otherDtos = $dto
}
not the best experience if dto should be immutable, but it also work with a `private modifier so it still can be immutable
so if I have a dto like
and retrieving it from the elastic search using
$index->getModel(1);
it's not converting$otherDtos
to instances ofThirdDto
, but simply return as an array of associative arrays.Here is the mapping file:
Is this not supported to use nested dto's, or maybe I'm doing something wrong?????