-
-
Notifications
You must be signed in to change notification settings - Fork 206
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 ? #236
Comments
At first glance, I think this should totally be possible. There is a method on the Registry class called Someone care to open a PR? |
As a possible solution, while the issue is solved, you can use groups in fixtures: Later, you can exec fixtures as:
This works for me on Symfony 4.2 👍 |
For now, groups seem to be the only way this can be done reliably. In fixture services, you could easily have the manager registry injected and then select the appropriate manager using the I'm not sure what a good way to solve this would be, apart from what @migueabellan suggested above. |
@alcaeus Don't we just change the default behavior so when an entity manager isn't specified we try to auto detect it for the objects? I just ran into this problem and the fix is pretty gross. I expected it to auto detect when not specifying the entity manager. |
The fixtures only receive a single entity manager. It is up to the fixture itself to ensure that the entity manager can actually handle the entity you want to create. When using multiple entity managers, it would definitely be advantageous to pass in the entire manager registry. I'm not sure how we can accomplish that without a hard BC break, but it could be a way to get rid of the |
I have multiple connections used by multiple entity managers with separate bundles (Symfony 3.4):
I have fixtures in both, but Doctrine seem to use only the default entity manager for both.
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.
Maybe there is some simpler way I'm not aware of.
The text was updated successfully, but these errors were encountered: