I need to set a dynamic connection just before doing the login_check action. I know I can set the entity manager before get Repository but I'm using FOSUserBundle for login and this bundle always connects against default connection. I need to change connection dynamically before login_check based on subdomain. Thanks
Asked
Active
Viewed 128 times
-1
-
possible duplicate of [Multiple entity manager for FOSUserBundle](http://stackoverflow.com/questions/14475180/multiple-entity-manager-for-fosuserbundle) – Marcel Burkhard Sep 02 '15 at 14:10
1 Answers
0
Because of a lack of information I have to assume you are using doctrine2.
You can configure multiple entity managers
Bascially you configure both of them in your config.yml and tell doctrine upon retrieval of an entity manager which one you need.
Example:
$this->get('doctrine')->getManager('default');
Here is the article:
http://symfony.com/doc/current/cookbook/doctrine/multiple_entity_managers.html
And because you only need it on certain occasions I advise you to look up the topics dependency injection and controller as a service.
Marcel Burkhard
- 3,453
- 1
- 29
- 35
-
Thanks @marcel ! I know that way but I need to set the connection just before login_check. I'm using FOSUserBundle that always use default entity manager to login – Hernan Sep 02 '15 at 14:04
-
Try this: http://stackoverflow.com/questions/14475180/multiple-entity-manager-for-fosuserbundle?rq=1 or this: http://stackoverflow.com/questions/18869233/fosuserbundle-with-multiple-entity-managers-symfony-2-set-up – Marcel Burkhard Sep 02 '15 at 14:05