Skip to content

Commit

Permalink
Deprecated alias on DI Extension
Browse files Browse the repository at this point in the history
  • Loading branch information
maxhelias committed Nov 28, 2019
1 parent 1035bdd commit 87b74f3
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
9 changes: 9 additions & 0 deletions DependencyInjection/DoctrineExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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']);
}
Expand Down
8 changes: 2 additions & 6 deletions Resources/config/dbal.xml
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,8 @@
<argument>%doctrine.default_entity_manager%</argument>
</service>
<service id="Doctrine\Common\Persistence\ManagerRegistry" alias="doctrine" public="false" />
<service id="Symfony\Bridge\Doctrine\RegistryInterface" alias="doctrine" public="false">
<deprecated>The "%alias_id%" service alias is deprecated, use `Doctrine\Common\Persistence\ManagerRegistry` instead.</deprecated>
</service>
<service id="Doctrine\Bundle\DoctrineBundle\Registry" alias="doctrine" public="false">
<deprecated>The "%alias_id%" service alias is deprecated, use `Doctrine\Common\Persistence\ManagerRegistry` instead.</deprecated>
</service>
<service id="Symfony\Bridge\Doctrine\RegistryInterface" alias="doctrine" public="false" />
<service id="Doctrine\Bundle\DoctrineBundle\Registry" alias="doctrine" public="false" />

<service id="doctrine.twig.doctrine_extension" class="Doctrine\Bundle\DoctrineBundle\Twig\DoctrineExtension" public="false">
<tag name="twig.extension" />
Expand Down
4 changes: 1 addition & 3 deletions Resources/config/orm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,7 @@
</parameters>

<services>
<service id="Doctrine\Common\Persistence\ObjectManager" alias="doctrine.orm.entity_manager" public="false">
<deprecated>The "%alias_id%" service alias is deprecated, use `Doctrine\ORM\EntityManagerInterface` instead.</deprecated>
</service>
<service id="Doctrine\Common\Persistence\ObjectManager" alias="doctrine.orm.entity_manager" public="false"/>
<service id="Doctrine\ORM\EntityManagerInterface" alias="doctrine.orm.entity_manager" public="false" />

<!--- Deprecated Annotation Metadata Reader Service alias, use annotation_reader service -->
Expand Down

0 comments on commit 87b74f3

Please sign in to comment.