diff --git a/DependencyInjection/DoctrineExtension.php b/DependencyInjection/DoctrineExtension.php
index 0498ef703..1fbf8b000 100644
--- a/DependencyInjection/DoctrineExtension.php
+++ b/DependencyInjection/DoctrineExtension.php
@@ -92,6 +92,11 @@ protected function dbalLoad(array $config, ContainerBuilder $container)
$loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
$loader->load('dbal.xml');
+ if (method_exists(Alias::class, 'setDeprecated')) {
+ $container->getAlias('Symfony\Bridge\Doctrine\RegistryInterface')->setDeprecated(true, 'The "%alias_id%" service alias is deprecated, use `Doctrine\Common\Persistence\ManagerRegistry` instead.');
+ $container->getAlias('Doctrine\Bundle\DoctrineBundle\Registry')->setDeprecated(true, 'The "%alias_id%" service alias is deprecated, use `Doctrine\Common\Persistence\ManagerRegistry` instead.');
+ }
+
if (empty($config['default_connection'])) {
$keys = array_keys($config['connections']);
$config['default_connection'] = reset($keys);
@@ -348,6 +353,10 @@ protected function ormLoad(array $config, ContainerBuilder $container)
$loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
$loader->load('orm.xml');
+ if (method_exists(Alias::class, 'setDeprecated')) {
+ $container->getAlias('Doctrine\Common\Persistence\ObjectManager')->setDeprecated(true, 'The "%alias_id%" service alias is deprecated, use `Doctrine\ORM\EntityManagerInterface` instead.');
+ }
+
if (class_exists(AbstractType::class)) {
$container->getDefinition('form.type.entity')->addTag('kernel.reset', ['method' => 'reset']);
}
diff --git a/Resources/config/dbal.xml b/Resources/config/dbal.xml
index df606b92d..72bc68d5c 100644
--- a/Resources/config/dbal.xml
+++ b/Resources/config/dbal.xml
@@ -65,12 +65,8 @@
%doctrine.default_entity_manager%
-
- The "%alias_id%" service alias is deprecated, use `Doctrine\Common\Persistence\ManagerRegistry` instead.
-
-
- The "%alias_id%" service alias is deprecated, use `Doctrine\Common\Persistence\ManagerRegistry` instead.
-
+
+
diff --git a/Resources/config/orm.xml b/Resources/config/orm.xml
index 336a2ad6a..e99be0253 100644
--- a/Resources/config/orm.xml
+++ b/Resources/config/orm.xml
@@ -75,9 +75,7 @@
-
- The "%alias_id%" service alias is deprecated, use `Doctrine\ORM\EntityManagerInterface` instead.
-
+