From 875b1382e41dc1fc445725384d7fc056df7805bd Mon Sep 17 00:00:00 2001 From: Robin Chalas Date: Sun, 2 Apr 2017 13:15:10 +0200 Subject: [PATCH] Remove legacy code from DI extension --- DependencyInjection/DoctrineExtension.php | 31 +---------------------- Resources/config/dbal.xml | 4 ++- Resources/config/orm.xml | 4 ++- 3 files changed, 7 insertions(+), 32 deletions(-) diff --git a/DependencyInjection/DoctrineExtension.php b/DependencyInjection/DoctrineExtension.php index 80ec9062a..9b49266d2 100644 --- a/DependencyInjection/DoctrineExtension.php +++ b/DependencyInjection/DoctrineExtension.php @@ -138,16 +138,6 @@ protected function dbalLoad(array $config, ContainerBuilder $container) $container->setParameter('doctrine.connections', $connections); $container->setParameter('doctrine.default_connection', $this->defaultConnection); - $def = $container->getDefinition('doctrine.dbal.connection'); - if (method_exists($def, 'setFactory')) { - // to be inlined in dbal.xml when dependency on Symfony DependencyInjection is bumped to 2.6 - $def->setFactory(array(new Reference('doctrine.dbal.connection_factory'), 'createConnection')); - } else { - // to be removed when dependency on Symfony DependencyInjection is bumped to 2.6 - $def->setFactoryService('doctrine.dbal.connection_factory'); - $def->setFactoryMethod('createConnection'); - } - foreach ($config['connections'] as $name => $connection) { $this->loadDbalConnection($name, $connection, $container); } @@ -374,26 +364,7 @@ protected function ormLoad(array $config, ContainerBuilder $container) $container->setAlias('doctrine.orm.entity_manager', sprintf('doctrine.orm.%s_entity_manager', $config['default_entity_manager'])); - // BC logic to handle DoctrineBridge < 2.6 - if (!method_exists($this, 'fixManagersAutoMappings')) { - foreach ($config['entity_managers'] as $entityManager) { - if ($entityManager['auto_mapping'] && count($config['entity_managers']) > 1) { - throw new \LogicException('You cannot enable "auto_mapping" when several entity managers are defined.'); - } - } - } else { - $config['entity_managers'] = $this->fixManagersAutoMappings($config['entity_managers'], $container->getParameter('kernel.bundles')); - } - - $def = $container->getDefinition('doctrine.orm.entity_manager.abstract'); - if (method_exists($def, 'setFactory')) { - // to be inlined in dbal.xml when dependency on Symfony DependencyInjection is bumped to 2.6 - $def->setFactory(array('%doctrine.orm.entity_manager.class%', 'create')); - } else { - // to be removed when dependency on Symfony DependencyInjection is bumped to 2.6 - $def->setFactoryClass('%doctrine.orm.entity_manager.class%'); - $def->setFactoryMethod('create'); - } + $config['entity_managers'] = $this->fixManagersAutoMappings($config['entity_managers'], $container->getParameter('kernel.bundles')); $loadPropertyInfoExtractor = interface_exists('Symfony\Component\PropertyInfo\PropertyInfoExtractorInterface') && class_exists('Symfony\Bridge\Doctrine\PropertyInfo\DoctrineExtractor'); diff --git a/Resources/config/dbal.xml b/Resources/config/dbal.xml index 71e163a9a..d9b9c1782 100644 --- a/Resources/config/dbal.xml +++ b/Resources/config/dbal.xml @@ -45,7 +45,9 @@ %doctrine.dbal.connection_factory.types% - + + + diff --git a/Resources/config/orm.xml b/Resources/config/orm.xml index 7a0dbbc21..604fbbb73 100644 --- a/Resources/config/orm.xml +++ b/Resources/config/orm.xml @@ -98,7 +98,9 @@ - + + +