Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default entity manager always used in fixtures ? #760

Closed
Glideh opened this issue Jan 17, 2018 · 2 comments
Closed

Default entity manager always used in fixtures ? #760

Glideh opened this issue Jan 17, 2018 · 2 comments

Comments

@Glideh
Copy link

Glideh commented Jan 17, 2018

I have multiple connections used by multiple entity managers with separate bundles (Symfony 3.4):

doctrine:
    dbal:
        default_connection: cnx1
        connections:
            cnx1:
#              ...
            cnx1:
#              ...
#           ...
    orm:
        default_entity_manager: em1
        entity_managers:
            em1:
                connection: cnx1
                mappings:
                    FirstBundle: ~
            em2:
                connection: cnx2
                mappings:
                    SecondBundle: ~
#           ...

I have fixtures in both, but Doctrine seem to use only the default entity manager for both.

$ console doctrine:fixtures:load -n

  > purging database
  > loading FirstBundle\DataFixtures\ORM\LoadEntity1Data
  > loading FirstBundle\DataFixtures\ORM\LoadEntity2Data
[...]
  > loading SecondBundle\DataFixtures\ORM\LoadEntity3Data

In MappingException.php line 37:

The class 'SecondBundle\Entity\Entity3' was not found
  in the chain configured namespaces FirstBundle\Entity

Is there a way to help Doctrine in our fixtures guessing which manager to use ?
This would avoid to have to use this for each distinct entity manager.

$ console doctrine:fixtures:load -n --em=em1 --fixtures=src/FirstBundle/DataFixtures/ORM
$ console doctrine:fixtures:load -n --em=em2 --fixtures=src/SecondBundle/DataFixtures/ORM

Maybe there is some simpler way I'm not aware of.

@weaverryan
Copy link
Contributor

Hey there!

You should re-open this issue on DoctrineFixturesBundle - https://github.com/doctrine/DoctrineFixturesBundle/issues

Cheers!

@Glideh
Copy link
Author

Glideh commented Feb 4, 2018

Done

@Glideh Glideh closed this as completed Feb 4, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants