Setup if condition in EntityToJsonTransformer.php for when 'me' is passed

This commit is contained in:
Julie Lenaerts 2025-03-11 09:27:03 +01:00
parent b130dbdcdc
commit 9503cb89b6

View File

@ -68,6 +68,17 @@ class EntityToJsonTransformer implements DataTransformerInterface
private function denormalizeOne(array|string $item) 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)) { if (!\array_key_exists('type', $item)) {
throw new TransformationFailedException('the key "type" is missing on element'); 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'); 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) { $class = match ($this->type) {
'user' => User::class, 'user' => User::class,
'person' => Person::class, 'person' => Person::class,
@ -109,5 +109,6 @@ class EntityToJsonTransformer implements DataTransformerInterface
'json', 'json',
$context, $context,
); );
} }
} }