diff --git a/DependencyInjection/DoctrineExtension.php b/DependencyInjection/DoctrineExtension.php index 23379f9bc..fc2467f7b 100644 --- a/DependencyInjection/DoctrineExtension.php +++ b/DependencyInjection/DoctrineExtension.php @@ -48,6 +48,8 @@ public function load(array $configs, ContainerBuilder $container) if (! empty($config['dbal'])) { $this->dbalLoad($config['dbal'], $container); + + $this->loadMessengerServices($container); } if (empty($config['orm'])) { @@ -58,10 +60,6 @@ public function load(array $configs, ContainerBuilder $container) throw new LogicException('Configuring the ORM layer requires to configure the DBAL layer as well.'); } - if (! class_exists(Version::class)) { - throw new LogicException('To configure the ORM layer, you must first install the doctrine/orm package.'); - } - $this->ormLoad($config['orm'], $container); } @@ -329,6 +327,10 @@ protected function getConnectionOptions($connection) */ protected function ormLoad(array $config, ContainerBuilder $container) { + if (! class_exists(Version::class)) { + throw new LogicException('To configure the ORM layer, you must first install the doctrine/orm package.'); + } + $loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config')); $loader->load('orm.xml'); @@ -387,8 +389,6 @@ protected function ormLoad(array $config, ContainerBuilder $container) $container->registerForAutoconfiguration(ServiceEntityRepositoryInterface::class) ->addTag(ServiceRepositoryCompilerPass::REPOSITORY_SERVICE_TAG); - - $this->loadMessengerServices($container); } /** diff --git a/Tests/DependencyInjection/DoctrineExtensionTest.php b/Tests/DependencyInjection/DoctrineExtensionTest.php index 0ec71d984..bd2e3e56c 100644 --- a/Tests/DependencyInjection/DoctrineExtensionTest.php +++ b/Tests/DependencyInjection/DoctrineExtensionTest.php @@ -664,12 +664,6 @@ public function testMessengerIntegration() $config = BundleConfigurationBuilder::createBuilder() ->addBaseConnection() - ->addEntityManager([ - 'default_entity_manager' => 'default', - 'entity_managers' => [ - 'default' => [], - ], - ]) ->build(); $extension->load([$config], $container);