治具-圆形参考 [英] Doctrine fixtures - circular references
问题描述
有什么方法可以加载具有循环参考的灯具?例如,我有以下固定装置:
Is there any way to load fixtures that have circular referencing? As an example I have the following fixture:
BusinessEntityTeam:
Nicole_Team:
name: Nicole's Team
Manager: [Nicole]
Business: [ACMEWidgets]
sfGuardUser
Nicole:
first_name: Nicole
last_name: Jones
email_address: nicole@example.com
username: nicole
password: nicole
Groups: [Group_abc]
Team: [Nicole_Team]
如您所见,Nicole_Team引用了Nicole ...,但Nicole也引用了Nicole_Team。
As you can see, Nicole_Team references Nicole... but Nicole also references Nicole_Team.
当Manager不是必需列时,可以(加载夹具,但Manager为NULL),但是现在需要不可能加载夹具。
When Manager wasn't a required column this was OK (the fixture loaded, but Manager was NULL), but now it's required it's impossible to load the fixture.
我可以看到的解决方法是将团队关系放在其自己的对象中(例如,个人资料),这样关系不再是循环的。
The only work-around I can see is to put the Team relation in its own object ('Profile' for example) so the relations are no longer circular.
是否存在其他任何关系方法?每个用户都必须在一个团队中,但是只有少数几个用户是团队经理。我很愿意接受这样的事实,即我的数据模型可能设计不良,并且还有改进的空间。
Is there any other approach? Every user has to be in a team, but only a few users are team managers. I'm quite open to the fact that my data model may be badly designed and have room for improvement.
推荐答案
:
BusinessEntityTeam:
Nicole_Team:
name: Nicole's Team
Business: [ACMEWidgets]
sfGuardUser
Nicole:
first_name: Nicole
last_name: Jones
email_address: nicole@example.com
username: nicole
password: nicole
Groups: [Group_abc]
Team: [Nicole_Team]
ManagerFor: [Nicole_Team]
为了避免循环引用,必须将关系放在一个模型中。
In order to avoid circular referencing, you have to put the relations in one model.
这篇关于治具-圆形参考的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!