I'm using Doctrine 2 where I have multiple connections for DBAL. I have also multiple EntityManagers in ORM.
I need to be able to somehow autowire specific DBAL connection into other Symfony 3 services.
I can autowire any EntitiyManager using EntityManagerDecorator but don't know how to do the same with connection. I'm able to get the connection from EntityManager but I don't think it's the way to go.
You can specify wrapper class for doctrine connections, no proxy class needed:
Connections should extend
Doctrine\DBAL\Connection
:and create service aliases:
then you can simply inject desired connection into service by typehinting it: