Skip to content

Commit

Permalink
Fix BC break with DoctrineType::reset() for Symfony 3.4-4.1
Browse files Browse the repository at this point in the history
Fixes BC break with mistakenly removed `kernel.reset` tag from
`form.type.entity` service, because `DoctrineType` implements
`ResetInterface` only in Symfony 4.2+, therefore all previous
versions starting from 3.4 are affected.

This BC break was introduced in version 1.11.0 in commit 6b25ea4
  • Loading branch information
javer committed May 16, 2019
1 parent 09a3841 commit 0b636c8
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions DependencyInjection/DoctrineExtension.php
Expand Up @@ -11,6 +11,7 @@
use Doctrine\ORM\Version;
use LogicException;
use Symfony\Bridge\Doctrine\DependencyInjection\AbstractDoctrineExtension;
use Symfony\Bridge\Doctrine\Form\Type\DoctrineType;
use Symfony\Bridge\Doctrine\Messenger\DoctrineTransactionMiddleware;
use Symfony\Bridge\Doctrine\PropertyInfo\DoctrineExtractor;
use Symfony\Bridge\Doctrine\Validator\DoctrineLoader;
Expand Down Expand Up @@ -343,6 +344,11 @@ protected function ormLoad(array $config, ContainerBuilder $container)
$loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
$loader->load('orm.xml');

// This check can be removed when support for Symfony < 4.2 is dropped
if (method_exists(DoctrineType::class, 'reset')) {
$container->getDefinition('form.type.entity')->addTag('kernel.reset', ['method' => 'reset']);
}

$entityManagers = [];
foreach (array_keys($config['entity_managers']) as $name) {
$entityManagers[$name] = sprintf('doctrine.orm.%s_entity_manager', $name);
Expand Down

0 comments on commit 0b636c8

Please sign in to comment.