Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove legacy code from DoctrineExtension #648

Merged
merged 1 commit into from
Apr 13, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 1 addition & 30 deletions DependencyInjection/DoctrineExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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');
Expand Down
4 changes: 3 additions & 1 deletion Resources/config/dbal.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@
<argument>%doctrine.dbal.connection_factory.types%</argument>
</service>

<service id="doctrine.dbal.connection" class="Doctrine\DBAL\Connection" abstract="true" />
<service id="doctrine.dbal.connection" class="Doctrine\DBAL\Connection" abstract="true">
<factory service="doctrine.dbal.connection_factory" method="createConnection" />
</service>

<service id="doctrine.dbal.connection.event_manager" class="%doctrine.dbal.connection.event_manager.class%" public="false" abstract="true">
<argument type="service" id="service_container" />
Expand Down
4 changes: 3 additions & 1 deletion Resources/config/orm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,9 @@

<service id="doctrine.orm.configuration" class="%doctrine.orm.configuration.class%" abstract="true" public="false" />

<service id="doctrine.orm.entity_manager.abstract" class="%doctrine.orm.entity_manager.class%" abstract="true" lazy="true" />
<service id="doctrine.orm.entity_manager.abstract" class="%doctrine.orm.entity_manager.class%" abstract="true" lazy="true">
<factory class="%doctrine.orm.entity_manager.class%" method="create" />
</service>

<!-- The configurator cannot be a private service -->
<service id="doctrine.orm.manager_configurator.abstract" class="%doctrine.orm.manager_configurator.class%" abstract="true">
Expand Down