【发布时间】:2016-05-27 15:32:51
【问题描述】:
我目前正在使用以下堆栈开发 API;
- Symfony (3)
- FOSRestBundle
- 分形
我想集成通过查询参数指定检索实体/集合时要包含哪些关系的功能,例如;
[GET] /users?include=friends.addresses
Fractal comes with the ability to handle includes 然而,由于这发生在响应构建的序列化点附近,每个相关实体都通过延迟加载检索,从而触发额外的查询。
有没有办法告诉 Doctrine 在检索集合时也动态检索指定的关系?我见过the following from the Doctrine docs which shows how to dynamically change the fetch mode,但这似乎只适用于目标实体上的关联(上例中的friends)而不是更深层次的关系(示例中的friends 中的addresses)。
谢谢!
【问题讨论】: