I have entity Company
with many Users
and User
has many Tokens
. I would like to serialize Token with User inside.
// @JMS\MaxDepth(depth=0)
Token::$user;
If I do this, the serialized result will be: {"token":{"id":2,"user":{},"token":"sxcdftrbgyijmko"}}
notice User is present. If I change MaxDepth to one, the company is missing in output. {"token":{"id":2,"user":{"id":2,"tokens":[],"name":"Martin"},"token":"sxcdftrbgyijmko"}}
. If I change MaxDepth to two, the company will be serialized as well. Why is company missing for depth one? I tried to achieve this behavior with groups but with same result.
I am using sideloading visitor and it is critical for me to keep there these empty fields so that visitor will turn them into ids. I also made minimal functional example on github.