Skip to content

Compatibility with Jane is not possible without hacky code #12

@damienalexandre

Description

@damienalexandre

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinghelp wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions