I'm using Symfony2 and JMSSerializerBundle to build an API. The system that JMSSerializer provides to set different ways of serializing objects using groups is quite useful, however, I'm missing a way to specify which group do you want to serialize in every parameter. Example:
I have an article that is related to a user (author). Articles as well as users can be serialized as "list" or as "details", however, I want the users to be serialized as "list" always that they are retrieved from the article (because "details" group is reserved to be used to fetch the user and just the user). The problem is that if I set the serializer as "details", then the author is also serialized as "details".
In my mind, the code should be something like:
/**
* @var SCA\APIBundle\Entity\User
* @Groups({"list" => "list", "details" => "list"})
*/
private $author;
where the key of the array indicates the way the parent should be serialized, and the value indicates the way the child should be serialized.
Any clue how can I achieve this?