diff --git a/DependencyInjection/DoctrineExtension.php b/DependencyInjection/DoctrineExtension.php index 249186d59..43fbb53d5 100644 --- a/DependencyInjection/DoctrineExtension.php +++ b/DependencyInjection/DoctrineExtension.php @@ -590,7 +590,10 @@ protected function ormLoad(array $config, ContainerBuilder $container) ]); } - $def->addTag('doctrine.event_subscriber'); + $def + ->addTag('doctrine.event_listener', ['event' => 'loadClassMetadata']) + ->addTag('doctrine.event_listener', ['event' => 'onClassMetadataNotFound']) + ; } $container->registerForAutoconfiguration(ServiceEntityRepositoryInterface::class) diff --git a/Tests/DependencyInjection/AbstractDoctrineExtensionTest.php b/Tests/DependencyInjection/AbstractDoctrineExtensionTest.php index 2c8989d01..aca2bd722 100644 --- a/Tests/DependencyInjection/AbstractDoctrineExtensionTest.php +++ b/Tests/DependencyInjection/AbstractDoctrineExtensionTest.php @@ -890,7 +890,7 @@ public function testResolveTargetEntity(): void $tags = $definition->getTags(); unset($tags['container.no_preload']); - $this->assertEquals(['doctrine.event_subscriber' => [[]]], $tags); + $this->assertEquals(['doctrine.event_listener' => [['event' => 'loadClassMetadata'], ['event' => 'onClassMetadataNotFound']]], $tags); } public function testSchemaIgnoreClasses(): void