Closed briancappello closed 10 years ago
Thanks @briancappello, really useful :+1:
Hope they will merge your PR soon. And then we should update composer.json
.
@kayue seems unlikely those are getting merged but a helpful comment from stof indicates that this bundle should be ensuring it uses a different entity manager than the default one in order to map the wordpress tables. Then the fixtures bundle wont end up truncating the wordpress tables. I think this is accurate and would be a good approach.
We would need to determine whether its possible to turn auto mapping on for most bundles except this one... being unable to use auto mapping would kind of be a bummer for us
http://symfony.com/doc/current/cookbook/doctrine/multiple_entity_managers.html
@benglass Multiple entity should be usable already, see: https://github.com/kayue/KayueWordpressBundle/blob/master/DependencyInjection/Configuration.php#L31
IIRC auto mapping is not possible when we use multiple entity.
It looks like in the doctrine config you can enable auto mapping for each entity manager but that would probably cause the default em to recognize the kayue entities. However I do see that there is a mapping config option for each mapping that is a bool so its possible a config like this MIGHT work. Ill look tomorrow
doctrine:
default_entity_manager: default
entity_managers:
default:
auto_mapping: true
mappings:
KayueWordpressBundle:
mapping: false
wordpress:
auto_mapping: false
mappings:
KayueWordpressBundle: ~
Even if its not possible via config I think its probably possible via a compiler pass that pulls the default entity manager or whatever service is used to load the entity mappings and somehow getting it to ignor kayue wordpress mappings.
Thanks @benglass . I did looked into auto mapping before but no luck. (the multisite functionality in this bundle require multiple entity). I don't have deep understanding of what Symfony's compiler does, so good luck :) Looking forward to see your result.
You are right you cant use auto mapping with more than 1 em https://github.com/doctrine/DoctrineBundle/blob/master/DependencyInjection/DoctrineExtension.php#L359
Going to research the compiler pass angle of blacklisting kayue bundle from the defautl entity manager
Well actually at this point it seems pretty clear cut to me that if you want to use this bundle with doctrine fixtures bundle that you need to not use auto mapping. You need to provide 2 entity managers, one for wordpress and one for your other entities and you need to explicitly map all of your bundles in the default entity manager. This seems like an unfortunately verbose solution in your config but it will resolve the problem of fixtures truncating the wordpress tables. This is how we will probably solve this problem in the future as every other solution we looked at seems like a hack.
FYI you can close this issue because the PRs it depends on are NOT going to be accepted by doctrine
Depends upon two upstream PRs getting accepted: https://github.com/doctrine/data-fixtures/pull/153 https://github.com/doctrine/DoctrineFixturesBundle/pull/120