h4cc_alice_fixtures.manager not honouring mapping configuration
Closed this issue · 9 comments
When I try to persist some fixtures using:
$manager = $client->getContainer()->get('h4cc_alice_fixtures.manager');
static::$fixtures = $manager->loadFiles(array(__DIR__ . '/../DataFixtures/product.yml',__DIR__ . '/../DataFixtures/itemProduct.yml'));
$manager->persist(static::$fixtures);
It fails with:
Doctrine\Common\Persistence\Mapping\MappingException: The class 'xxx\yyyBundle\Entity\Item' was not found in the chain configured namespaces
Because is not honouring the config.yml mapping configuration when you have multiple entity managers.
I think this is a good read on that:
http://php-and-symfony.matthiasnoback.nl/2014/05/inject-the-manager-registry-instead-of-the-entity-manager/
Thanks for that hint, will get on it.
@h4cc I tried to fix it somehow but I'm quite new to Symfony and lack the
knowledge, feel free to have a look at my forked repo which at least works
for my needs.
@garciall Does it work? You can tes the branch using this composer requirement:
"h4cc/alice-fixtures-bundle": "dev-feature/doctrine-manager-registry"
@h4cc I tried this yesterday and it works smoothly!
I just found another issue, I have some fixtures which are related using a join table which uses associationKey for its primary key. Imagine having Item <> ItemProduct <> Product. If I try to load all the fixtures at the same time, i.e. Item, Product and then ItemProduct it fails on the last cause it lacks an autogenerated id for the first two, is there any way to force a flush between fixtures loading?
You could seperate it into two sets, there will be a flush after each one.
Ok! I'll try that 👍
Thank you for testing, will prepare this for a v0.4 release.
Released with 0.4:
https://github.com/h4cc/AliceFixturesBundle/releases/tag/0.4.0