Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can symfony serializer deserialize return nested entity of type child entity?

When I deserialize my doctrine entity, the initial object is constructed/initiated correctly, however all child relations are trying to be called as arrays.

The root level object's addChild(ChildEntity $entity) method is being called, but Symfony is throwing an error that addChild is receiving an array and not an instance of ChildEntity.

Does Symfony's own serializer have a way to deserialize nested arrays (child entities) to the entity type?

JMS Serializer handles this by specifying a @Type("ArrayCollection<ChildEntity>") annotation on the property.

like image 794
mr12086 Avatar asked Aug 13 '15 22:08

mr12086


1 Answers

I believe the Symfony serializer attempts to be minimal compared to the JMS Serializer, so you might have to implement your own denormalizer for the class. You can see how the section on adding normalizers.

like image 81
mickadoo Avatar answered Sep 28 '22 18:09

mickadoo