How to embed the @session service in a custom EntityManager in Symfony2

In my configuration file, I defined a custom object manager:

parameters:
    doctrine.orm.entity_manager:
        class: Strict\UserBundle\Entity\Manager\MyEntityManager

Is there a way to inject / add the @session service (I need to access the getLocale () method) in this entity manager? I tried this:

parameters:
    doctrine.orm.entity_manager:
        class: Strict\UserBundle\Entity\Manager\MyEntityManager
        arguments: 
            session: "@session"

but it throws this exception:

InvalidArgumentException: You cannot dump a container with parameters that contain references to other services (reference to service "session" found in "/doctrine.orm.entity_manager/arguments/session").

Any ideas?

+5
source share
1 answer

Parameters do not allow services as arguments; you tried to do the same, but using a service:

service:
   my.entity.manager:
      class: Strict\UserBundle\Entity\Manager\MyEntityManager
      arguments: 
        session: "@session"
+16
source

All Articles