Reputation: 1539
I am new to Doctrine Symfony framework and want to understand how entity manager works in multi-threaded environment.
I have service class called ProxyDelegator
which is called every time service method is called.
app.ProxyDelegator:
class: Acme\SampleBundle\Controller\ProxyDelegator
arguments: [@doctrine.orm.entity_manager]
This class will receive entity manager passed as above and create the transaction and then it invoke the service method with reflection. This will help developers not to handle transaction management every time.
So the flow will be Controller ->
ProxyDelegator
(Create Transaction from entity manager) ->
Service Method (invoked from ProxyDelegator
using reflection).
My question is will it create the new entity manager for every new client request? If not how should I handle this scenario?
Thanks in advance.
Upvotes: 2
Views: 1492
Reputation: 29912
As far as I know, EntityManager
IS NOT a singleton so, everytime you invoke it, you'll get a brand new one.
If you want to try yourself, just print out result of spl_object_hash
Upvotes: 3