From 9503cb89b607334cc09325eb9f69506a13d2b513 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Tue, 11 Mar 2025 09:27:03 +0100 Subject: [PATCH] Setup if condition in EntityToJsonTransformer.php for when 'me' is passed --- .../EntityToJsonTransformer.php | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/EntityToJsonTransformer.php b/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/EntityToJsonTransformer.php index b51601caf..1863e8579 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/EntityToJsonTransformer.php +++ b/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/EntityToJsonTransformer.php @@ -68,6 +68,17 @@ class EntityToJsonTransformer implements DataTransformerInterface private function denormalizeOne(array|string $item) { + if ('me' === $item) { + dump($item); +/* return + $this->denormalizer->denormalize( + // pass id of current user that we get from the exportGenerationContext... + ['type' => User::class, 'id' => $item['id']], + User::class, + 'json', + $context, + );*/ + } if (!\array_key_exists('type', $item)) { throw new TransformationFailedException('the key "type" is missing on element'); } @@ -76,17 +87,6 @@ class EntityToJsonTransformer implements DataTransformerInterface throw new TransformationFailedException('the key "id" is missing on element'); } - if ('me' === $item) { - // return the denormalized current user - /* return - $this->denormalizer->denormalize( - ['type' => $item['type'], 'id' => $item['id']], - User::class, - 'json', - $context, - );*/ - } - $class = match ($this->type) { 'user' => User::class, 'person' => Person::class, @@ -109,5 +109,6 @@ class EntityToJsonTransformer implements DataTransformerInterface 'json', $context, ); + } }