Hi Sebastian, EntityRepository::getEntityManager() is there to use within the EntityRepository, but it's not the place to access it from outside of the EntityRepository.
Somewhere in the configuration/bootstrap phase of your application you create an EntityManager and store it so you can use it. In frameworks using dependency injection, you can fetch the EntityManager from the dependency container. Other frameworks might use a registry where you can fetch it from. Think of it this way: If you want to get the EntityManager from an EntityRepository, you first need to get that EntityRepository from the EntityManager. So you'll be running in circles this way ;) -- Jasper N. Brouwer (@jaspernbrouwer) On 31 Jan 2014, at 15:21, Sebastian Krebs <[email protected]> wrote: > Hi, > > A quite vague question, which was probably asked a houndred times before ;) > > Does anybody know, why is the "getEntityManager()"-method of the > EntityRepository is protected? There are also no other method exposed, to > persist an entity. I ask, because right know I have to carry around the > repositories I want to use alongside with their corresponding entity-managers > to both load and save entities. > > The subject is about ObjectManager, so yeah: This question slightly covers > the other implementations as well. > > Regards, > Sebastian -- You received this message because you are subscribed to the Google Groups "doctrine-user" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/doctrine-user. For more options, visit https://groups.google.com/groups/opt_out.
