Hi, I'm searching for a way to override associations mapping in subclasses. I saw this part of documentation but, unless I didn't understand something, it doesn't give me an answer:
http://doctrine-orm.readthedocs.org/en/latest/tutorials/override-field-association-mappings-in-subclasses.html Let's take this example: /** * @Entity */class User { /** * @ManyToMany(targetEntity="Group") * @var Group[] */ protected $groups;} /** * @Entity */class Group { /** * @ManyToMany(targetEntity="Role") * @var Role[] */ protected $roles;} /** * @Entity */class Role { /** * @ManyToOne(targetEntity="RoleType") * @var RoleType */ protected $type;} /** * @Entity */class RoleType { } I use this as a base package to manage user. Now in a project, I need very specific stuff about RoleType, and need to add some DB columns to this table. Some stuff that has nothing to do in a base package. I would normally do something like this: /** * @Entity */class GreatRoleType extends RoleType { /** * Add some custom fields and/or custom associations */} Now I need to reference this GreatRoleType from my Role class, so I need to extend it as well /** * @Entity */class GreatRole extends Role { /** * Changing the targetEntity to load my custom type for the role * @ManyToOne(targetEntity="GreatRoleType") * @var GreatRoleType */ protected $type;} ... But then, I need to extend the Group class to target GreatRole instead of Role. And in the end, I need to extend User to target GreatGroup (which targets GreatRole, which targets GreatRoleType) Is there a way to avoid this cascade of extends? Or is there a best practice out there that is totally different from what I did? Do I need to use MappedSuperClasses? In the end, when I fetch a User, I would like to join Group, Role and RoleType. If I change the last for GreatRoleType, I will need to update the whole chain of joins. Because ->from('User', 'u')->leftJoin('u.groups', 'g')->leftJoin('g.roles', 'r')->leftJoin('r.type', 't'); will fetch explicitely User, Group, Role and RoleType. Thanks for your help! -- You received this message because you are subscribed to the Google Groups "doctrine-user" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/doctrine-user. For more options, visit https://groups.google.com/d/optout.
