1

I am working on a Web App using Symfony2 and I'd like to make a facebook friend request like system.

User "A" ask permission to user "B" to do something. User "B" should see a notification asking confirmation.

I asked my self what is a good way to do that. I though about creating an entity "request" whit User "A" (Object), User "B" (user_id field, using ManyToOne relation in Doctrine), Type (string) and Date field.

However, using object type will serialize the User "A". It seems a little heavy. And Using User "A" id instead of all object is not really Object Programming friendly.

4

1 回答 1

2

你绝对是在正确的轨道上。这就是你应该在 Symfony2 中使用 Doctrine2 的方式。

创建一个Request包含以下字段的实体:

  • id
  • sender(与用户实体的多对一关系)
  • receiver(也是与用户实体的多对一关系)
  • date
  • 无论您使用更多字段

或者,根据您的目标,您可以直接向FriendshiporAction实体添加一行并处理一个字段confirmedconfirmed_time分别为 NULL 的字段,直到友谊/动作得到确认或完成。

于 2013-04-15T13:48:44.963 回答