Skip to content
This repository has been archived by the owner on Jan 17, 2022. It is now read-only.

Commit

Permalink
fix(doctrine): autoconfigure EntityManagerHandler only when orm is av…
Browse files Browse the repository at this point in the history
…ailable in symfony's container (#274)
  • Loading branch information
k911 authored Jul 14, 2020
1 parent b9df907 commit 87ede15
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,9 @@ private function registerHttpServerServices(array $config, ContainerBuilder $con
;
}

if ($config['entity_manager_handler'] || (null === $config['entity_manager_handler'] && \interface_exists(EntityManagerInterface::class) && $this->isBundleLoaded($container, 'doctrine'))) {
if ($config['entity_manager_handler'] || (
null === $config['entity_manager_handler'] && $this->isDoctrineEntityManagerConfigured($container)
)) {
$container->register(EntityManagerHandler::class)
->addArgument(new Reference(EntityManagerHandler::class.'.inner'))
->setAutowired(true)
Expand Down Expand Up @@ -385,6 +387,13 @@ private function isBundleLoaded(ContainerBuilder $container, string $bundleName)
return isset($bundles[$fullBundleName]);
}

private function isDoctrineEntityManagerConfigured(ContainerBuilder $container): bool
{
return \interface_exists(EntityManagerInterface::class) &&
$this->isBundleLoaded($container, 'doctrine') &&
$container->has(EntityManagerInterface::class);
}

private function isProd(ContainerBuilder $container): bool
{
return 'prod' === $container->getParameter('kernel.environment');
Expand Down

0 comments on commit 87ede15

Please sign in to comment.