1

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.

Community
  • 1
  • 1
Keo
  • 1,143
  • 8
  • 19
  • The answer lies in the sideloading custom visitor. If you remove that the depth annotations work as expected. – noetix Mar 25 '15 at 03:16
  • Are you sure? I rechecked it and my examples provided here are from that project with commented out visitor. – Keo Mar 25 '15 at 08:59

0 Answers0