I have a Core config Database, each row is an 'App' with some basic config etc.
Once you have chosen your app, I want to connect to a database using a property of that row (ID), and the host may also change based on the row.
What I want is to register a service that sets up the Doctrine service using these details if you are in a place on the site that it's required (which I know based on URI).
I am using the Entity manager, and various Doctrine Listeners/Event subs
I've played around with the ConnectionFactory, but this appears to cause problems with the subscribers.
What is the best way to hook something up that will transparently modify the Doctrine service, so that the controllers can act without any knowledge of which DB host and DB name they are connecting to?
Each DB of this type will have the same structure so all Entity mapping is correct.
I'm looking for a really clean implementation, hopefully using the Service Container to avoid any 'hacks'.
Does anyone have any knowledge of doing this?
See Question&Answers more detail:os