mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
Question: Why is Doctrine\ORM\EntityRepository#getEntityManager() protected? #5634
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @spackmat on GitHub (Aug 11, 2017).
Originally assigned to: @Ocramius on GitHub.
Hi,
I am refactoring my Symfony controllers to get the EntityRepositories injected instead of the whole EntityManager. This works fine, but in some cases (transactions, changing listeners etc.), I still need access to the EntityManager.
But the Doctrine\ORM\EntityRepository#getEntityManager() method is protected. This surely is intentional, so my question is: Would it be bad practice to access the EntityManager through (injected) repositories? Or are there other reasons for the protection?
Greets,
spackmat