Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reset EntityManager via reinitialization, instead of removing from container #104

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

JanMikes
Copy link
Contributor

This fixes situations, when entity manager is closed properly - because removing the EntityManager from container does not fix closed entity manager in existing instances of services in DI container - it can be achieved only this way.

Inspired by how it is solved in Symfony framework.

Tested and it works, tested only with single entity manager / connection, can not guarantee this will work with multiple connections.

$this->container->removeService($name);
/** @var EntityManagerDecorator $manager */
$manager = $this->container->getService($name);
$wrapped = $this->container->createInstance(\Doctrine\ORM\EntityManager::class);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you pls import class? :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants