I’m having issues specific to Doctrine ORM Entity mapping and overriding vendor entities from the EkinoWordpressBundle. I understand there is some functionality to override the default bundle entities in the bundle. When I run doctrine:schema:update I get SchemaExceptions like ‘table with name wp_users’ already exists. I’m trying to figure out how to have the default doctrine mapping for an entity to be ignored from the bundle to avoid this issue.
What I have done so far is:
- create entities to replace the User and UserMeta from the bundle.
- I defined ekino.wordpress.entity.user.class: MyBundleNamespaceUser and ekino.wordpress.entity.user_meta.class: MyBundleNamespaceUserMeta in config.yml
- I’m using doctrine.orm.resolve_target_entities to replace association references to EkinoWordpressBundleEntityUser and EkinoWordpressBundleEntityUserMeta with my own
I’m not clear on defining custom entity managers and how that would help alleviate my issues as was suggested by the developer of the bundle https://github.com/ekino/EkinoWordpressBundle/issues/71
Also I’m using yml based mapping definition in case that makes a difference to possible solutions.
It seems likely that Doctrine is still thinking that the Ekino ‘User’ is still an entity, rather than using yours exclusively. I’m not familiar with Ekino. If it uses Annotation based configuration, you might have to create your own AnnotationDriver subclass and have it filter out the Ekino classes you don’t want.
It’s actually quite fun to play around in the lower-level code of the ClassMetadata, but do so at your own peril.
I got some help from a buddy who helped me understand what the suggested solution from the maintainer was asking me to do originally.
So in my config.yml I have the following for my doctrine configurations
This solves part of the problem. I don’t get the original SchemaExceptions I was getting regarding tables that already existed. Since I was only replacing two of the entities from the bundle some of the associations where no longer in the ClassMetadata from the original entities so I was getting additional errors regarding missing entities which was solved by tacking on the following to the
doctrine:orm:
configuration definition:I ended up loosing doctrine automapping by having to define separate entity managers but I think it’s an okay compromise.