tl;dr How does the getManagerForClass()
method find out which entity manager is the right one for a specific class?
I\'ve made a generic controller that
At long last, I solved it.
The solution was using the prefix
parameter.
entity_managers:
postgres:
connection: postgres
mappings:
AppBundle:
type: annotation
dir: Entity\Postgres
prefix: AppBundle\Entity\Postgres
alias: Postgres
oracle:
connection: oracle
mappings:
AppBundle:
type: annotation
dir: Entity\Oracle
prefix: AppBundle\Entity\Oracle
alias: Oracle
The prefix
parameter gets passed to the corresponding Entity Manager service, and is added to the entityNamespaces
property, which otherwise defaults to AppBundle/Entity
.
The Annotation Driver will then check for annotations in that specific namespace, whereas the File Driver checks for existing mapping files in the directory specified through the dir
parameter.
(The alias
parameter is not mandatory.)
At least, that's how I understand it.