Elastica always reads the JSON from Elasticsearch inside an associative array (and we cannot change that without rewriting a lot of code).
So when it's time for Elastically to hydrate the DTO, we only have the array version of our "_source".
This is not an issue on the default installation of Elastically but when using Jane as the DTO + Normalizer source, it breaks.
Jane Normalizer expects stdObject, not arrays.
The quick and dirty hack to fix this is to run:
$source = json_decode(json_encode($source), false);
Before:
|
return $this->client->getSerializer()->denormalize($data, $indexToClass[$pureIndexName], null, $context); |
How can we fix this in an elegant and robust way?
cc @Korbeil @joelwurtz @lyrixx
Error:
PHP Fatal error: Uncaught Symfony\Component\Serializer\Exception\InvalidArgumentException: Given $data is not an object (array given). We need an object in order to continue denormalize method.
Elastica always reads the JSON from Elasticsearch inside an associative array (and we cannot change that without rewriting a lot of code).
So when it's time for Elastically to hydrate the DTO, we only have the array version of our "_source".
This is not an issue on the default installation of Elastically but when using Jane as the DTO + Normalizer source, it breaks.
Jane Normalizer expects
stdObject, not arrays.The quick and dirty hack to fix this is to run:
Before:
elastically/src/ResultSetBuilder.php
Line 65 in bcb348f
How can we fix this in an elegant and robust way?
cc @Korbeil @joelwurtz @lyrixx
Error: