static method on EntityManager makes impossible to override entityManager class #5312

Closed
opened 2026-01-22 15:04:09 +01:00 by admin · 1 comment
Owner

Originally created by @wolfwolker on GitHub (Nov 4, 2016).

Originally assigned to: @Ocramius on GitHub.

the last line of this method is return new EntityManager(...), so if you try to override this class you need to copy/paste the whole method for only this purpose. This is mentioned here http://stackoverflow.com/questions/8138962/is-there-a-way-to-specify-doctrine2-entitymanager-implementation-class-in-symfon and in some other sOverflow's topic

I think a solution could be end this method with return new static(...) instead.

Sorry if this topic is duplicated, I wasn't able to found it either in issues nor pr section.

Originally created by @wolfwolker on GitHub (Nov 4, 2016). Originally assigned to: @Ocramius on GitHub. the last line of this method is return new EntityManager(...), so if you try to override this class you need to copy/paste the whole method for only this purpose. This is mentioned here http://stackoverflow.com/questions/8138962/is-there-a-way-to-specify-doctrine2-entitymanager-implementation-class-in-symfon and in some other sOverflow's topic I think a solution could be end this method with return new static(...) instead. Sorry if this topic is duplicated, I wasn't able to found it either in issues nor pr section.
admin added the ImprovementWon't Fix labels 2026-01-22 15:04:09 +01:00
admin closed this issue 2026-01-22 15:04:11 +01:00
Author
Owner

@Ocramius commented on GitHub (Nov 4, 2016):

You should either use an EntityManagerDecorator, or re-implement the
EntityManagerInterface.

On 4 Nov 2016 12:14, "Noel Garcia" notifications@github.com wrote:

the last line of this method is return new EntityManager(...), so if you
try to override this class you need to copy/paste the whole method for only
this purpose. This is mentioned here http://stackoverflow.com/
questions/8138962/is-there-a-way-to-specify-doctrine2-
entitymanager-implementation-class-in-symfon and in some other
sOverflow's topic

I think a solution could be end this method with return new static(...)
instead.

Sorry if this topic is duplicated, I wasn't able to found it either in
issues nor pr section.


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/doctrine/doctrine2/issues/6115, or mute the thread
https://github.com/notifications/unsubscribe-auth/AAJakCEJC-PikFnH8Zt3iUUKMf-s49Ndks5q6xN7gaJpZM4KpbRE
.

@Ocramius commented on GitHub (Nov 4, 2016): You should either use an EntityManagerDecorator, or re-implement the EntityManagerInterface. On 4 Nov 2016 12:14, "Noel Garcia" notifications@github.com wrote: > the last line of this method is return new EntityManager(...), so if you > try to override this class you need to copy/paste the whole method for only > this purpose. This is mentioned here http://stackoverflow.com/ > questions/8138962/is-there-a-way-to-specify-doctrine2- > entitymanager-implementation-class-in-symfon and in some other > sOverflow's topic > > I think a solution could be end this method with return new static(...) > instead. > > Sorry if this topic is duplicated, I wasn't able to found it either in > issues nor pr section. > > — > You are receiving this because you are subscribed to this thread. > Reply to this email directly, view it on GitHub > https://github.com/doctrine/doctrine2/issues/6115, or mute the thread > https://github.com/notifications/unsubscribe-auth/AAJakCEJC-PikFnH8Zt3iUUKMf-s49Ndks5q6xN7gaJpZM4KpbRE > .
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#5312