type variable added and file renamed in transformer

This commit is contained in:
Julie Lenaerts 2022-01-21 15:01:12 +01:00
parent c736c2b5bb
commit b26d0905a3

View File

@ -25,13 +25,16 @@ class UserToJsonTransformer implements DataTransformerInterface
private bool $multiple;
private string $type;
private SerializerInterface $serializer;
public function __construct(DenormalizerInterface $denormalizer, SerializerInterface $serializer, bool $multiple)
public function __construct(DenormalizerInterface $denormalizer, SerializerInterface $serializer, bool $multiple, string $type)
{
$this->denormalizer = $denormalizer;
$this->serializer = $serializer;
$this->multiple = $multiple;
$this->type = $type;
}
public function reverseTransform($value)
@ -72,7 +75,7 @@ class UserToJsonTransformer implements DataTransformerInterface
return
$this->denormalizer->denormalize(
['type' => $item['type'], 'id' => $item['id']],
['type' => $this->type, 'id' => $item['id']],
User::class,
'json',
[AbstractNormalizer::GROUPS => ['read']],