Elyass
Elyass

Reputation: 736

Doctrine : Relation with undefined/multiple entities

I need to create an like/dislike system which can be used on any entity. I'm going to create a Like entity with an 'Id', 'Entity' (can be anything), 'author' (ManyToOne with User class) and 'like' (boolean).

I just want to know if there is a good way to do it ? I can't use the table inheritance (mappedsuperclass) because this entity will be part of a bundle (SocialBundle) which can be used on several project (It will be a vendor).

I have no code to show you because i'm still in the analysis part.

Thanks !

Upvotes: 0

Views: 59

Answers (1)

Jan Mares
Jan Mares

Reputation: 805

Create an interface for that entity and later you can map this interface to any entity using addResolveTargetEntity method. See this.

Upvotes: 1

Related Questions