Lets say I have following structure:
Article:
- name
- content
- galleries: array of Gallery
Gallery:
- name
- description
- media : array of Media
- thumbnail: Media
Media:
- name
- file
Now when I am serializing The article or something that contains a gallery I need to specify groups for all children like this:
'groups' => [
'All',
'gallery' => [
'Details',
'thumbnail' => ['Basic'],
],
],
Now every time I add something to the gallery I need to go thorough all controllers and add the deep dependencies eg. After adding a largeThumbnail field:
'groups' => [
'All',
'gallery' => [
'Details',
'thumbnail' => ['Basic'],
'largeThumbnail' => ['Basic'],
],
],
If I dont do it, or miss a controller, it will include "largeThumbnail" with group "Details" instead of "Basic" and cause a lot of databasse requests (since without Groups defined it will just follow the tree and add everything it finds) killing the performance.
Is there a way to tell JMS what groups an entities children should have when a specific group is used for parent?
In other words can I tell that if I used "Details" For Gallery than it should use "Basic" for Gallery->media, so I can simplify the above to just saying:
'groups' => [
'All',
'gallery' => ['Details'],
],
And it would fill in 'thumbnail' => ['Basic'],
for me?