You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi i got a question about the DoctrineServiceProvider specifically about singleton binding for 'em'.
Here's a snippet of the DoctrineServiceProvider.
/** * Setup the entity manager */protectedfunctionregisterEntityManager()
{
// Bind the default Entity Manager$this->app->singleton('em', function ($app) {
return$app->make('registry')->getManager();
});
$this->app->alias('em', EntityManager::class);
$this->app->alias('em', EntityManagerInterface::class);
}
/** * Register the manager registry */protectedfunction registerManagerRegistry()
{
$this->app->singleton('registry', function ($app) {
$registry = newIlluminateRegistry($app, $app->make(EntityManagerFactory::class));
// Add all managers into the registryforeach ($app->make('config')->get('doctrine.managers', []) as$manager => $settings) {
$registry->addManager($manager, $settings);
}
return$registry;
});
I get that we need it to be a singleton instance for em.
But when i want to reset the entity manager via the registry (IlluminateRegistry::resetManager())
The reset entity manager is not rebound because of the singleton binding of 'em'.
So since the IlluminateRegistry is already singleton, i think changing the singleton binding to non singleton should be applicable.
I want to ask if this is intentional to bind the 'em' as the singleton because when i want to reset the manager i don't want to rebind the bound 'em' in the Container.
Thank you
The text was updated successfully, but these errors were encountered:
Now that you mention problem #398, i think rebinding the em would not solve the problem but will just cause further problems in the application state.
For example, if i got a customized event subscriber on the EntityManager, i think all the subscribed event in the em will be gone to, as it is a completely new instance.
I think it'd just be better to just restart the application on closed em, rather than resetting the manager.
Package version 1.5.5, Laravel version 6.17.1
Hi i got a question about the DoctrineServiceProvider specifically about singleton binding for 'em'.
Here's a snippet of the DoctrineServiceProvider.
I get that we need it to be a singleton instance for em.
But when i want to reset the entity manager via the registry (IlluminateRegistry::resetManager())
The reset entity manager is not rebound because of the singleton binding of 'em'.
So since the IlluminateRegistry is already singleton, i think changing the singleton binding to non singleton should be applicable.
I want to ask if this is intentional to bind the 'em' as the singleton because when i want to reset the manager i don't want to rebind the bound 'em' in the Container.
Thank you
The text was updated successfully, but these errors were encountered: