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 14, 2019
1 parent 09a3841 commit 632cbb6
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 All @@ -23,6 +24,7 @@
use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Messenger\MessageBusInterface;
use Symfony\Component\Messenger\Transport\Doctrine\DoctrineTransportFactory;
use Symfony\Component\PropertyInfo\PropertyAccessExtractorInterface;
Expand Down Expand Up @@ -343,6 +345,10 @@ protected function ormLoad(array $config, ContainerBuilder $container)
$loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
$loader->load('orm.xml');

if (class_exists(AbstractType::class) && 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 632cbb6

Please sign in to comment.