After looking for a solution on how to reset a Doctrine Entity Manager after a duplicate key exception, I found this thread: The entitity manager is closed
One of the answers mentions the resetManager()
method, which seems to be correct according to the documentation:
$em = $this->getDoctrine()->resetManager();
Unfortunaly, when calling resetManager()
, I get the following excpetion:
Resetting a non-lazy manager service is not supported. Set the "doctrine.orm.default_entity_manager" service as lazy and require "symfony/proxy-manager-bridge" in your composer.json file instead.
I've installed the package but can't find a way to mark the default manager as lazy. I have tried in my services.yaml
:
doctrine.orm.default_entity_manager:
lazy: true
But this lead to further errors. How do I define the default entity manager as lazy without having to re-specify the manager completely? The documentation for lazy services also didn't really help.
Thanks!