Using multiple entity managers in Symfony2

When using a single Symfony2 install to manage multiple web-apps, each with its own database, you can set up multiple entity managers and tell each bundle which manager to use.

One thing that stumped me, and has seemed to stump others judging by a quick Google, is how to inject a non-default entity manager into a service.

Turns out, the way to do it use [name]_entity_manager, instead of entity_manager in the arguments line of services.yml. So, if you have an entity manager called ‘other’, use this:

         class: Me\MyBundle\Form\Selector\ProjectSelectorType
         arguments: ["@doctrine.orm.other_entity_manager"]