I have just run myself into this tricky situation.
I have an entity called Gift.
Now the gift entity needs to have a field called receiver which can be associated with 2 entities RegisteredUser entity OR Guest entity.
The problem here is now how do I define the association for the receiver field!!
I thought of creating an entity called GiftReceiver use inheritance mapping but I cannot map the discriminator to a class which does not extend GiftReceiver.
Am I going the wrong way? Is there a good way to implement this?
Thanks in advance for your help!! 🙂
how about making a subclass of
UserasGuestand you can just map the receiver field toUserentity.When you fetch the receiver entity on the
Gift, doctrine will fetch the appropriate objectGuestorRegisteredUser