Fix: urgent fix for EntityToJsonTransformer

The throw on error flag imposes us to propose a valid json string for decoding
This commit is contained in:
Julien Fastré 2023-04-28 23:16:13 +02:00
parent 7e19419861
commit 24c33b306b
Signed by: julienfastre
GPG Key ID: BDE2190974723FCB

View File

@ -31,6 +31,10 @@ class EntityToJsonTransformer implements DataTransformerInterface
public function reverseTransform($value) public function reverseTransform($value)
{ {
if ("" === $value) {
return null;
}
$denormalized = json_decode($value, true, 512, JSON_THROW_ON_ERROR); $denormalized = json_decode($value, true, 512, JSON_THROW_ON_ERROR);
if ($this->multiple) { if ($this->multiple) {
@ -44,10 +48,6 @@ class EntityToJsonTransformer implements DataTransformerInterface
); );
} }
if ('' === $value) {
return null;
}
return $this->denormalizeOne($denormalized); return $this->denormalizeOne($denormalized);
} }