简体   繁体   中英

Extending a Doctrine entity to add extra association mapping in Symfony2

I currently have a User Doctrine entity and model in my Components. I have a User Bundle that does the basics of working with users, CRUD, etc.

I am developing a resource allocation bundle and I want to extend my User entity to add extra associations without changing the original user. Then the ResourceAllocation Bundle will be completely separate from the User Bundle.

I have setup a mapped superclass of BaseUser, which both User and SkilledUser (the one from the Resource Allocation Bundle). This however, tries to create a table for both User and SkilledUser which is undesired.

The user and skilled user could be the same user, so, Single Table Inheritance is not going to work.

Effectively, the end result should be one table with the users in.

We are working in YAML if answers could keep to this method, that would be great.

"Effectively, the end result should be one table with the users in."

The only way to achieve this is with STI (Single Table Inheritance).

"The user and skilled user could be the same user, so, Single Table Inheritance is not going to work."

I don't see how this matters... you can still create an association between User and SkilledUser if that is what you mean here.

See reference: http://doctrine-orm.readthedocs.org/en/latest/reference/inheritance-mapping.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM