Skip to content

Commit

Permalink
fix Doctrine bridge version detection
Browse files Browse the repository at this point in the history
Since we cannot use feature changes to detect which version of the
Doctrine bridge is installed I suggest that we parse the changelog and
check if entries for 4.2 are present.
  • Loading branch information
xabbuh committed Feb 4, 2019
1 parent dc8feee commit ee7e19c
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions DependencyInjection/DoctrineExtension.php
Expand Up @@ -11,6 +11,7 @@
use LogicException;
use Symfony\Bridge\Doctrine\DependencyInjection\AbstractDoctrineExtension;
use Symfony\Bridge\Doctrine\Form\Type\DoctrineType;
use Symfony\Bridge\Doctrine\ManagerRegistry;
use Symfony\Bridge\Doctrine\Messenger\DoctrineTransactionMiddleware;
use Symfony\Bridge\Doctrine\PropertyInfo\DoctrineExtractor;
use Symfony\Component\Config\FileLocator;
Expand All @@ -25,7 +26,7 @@
use Symfony\Component\DependencyInjection\ServiceLocator;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Messenger\MessageBusInterface;
use Symfony\Component\PropertyInfo\PropertyInitializableExtractorInterface;
use ReflectionClass;

/**
* DoctrineExtension is an extension for the Doctrine DBAL and ORM library.
Expand Down Expand Up @@ -800,7 +801,9 @@ protected function loadOrmCacheDrivers(array $entityManager, ContainerBuilder $c
private function loadPropertyInfoExtractor($entityManagerName, ContainerBuilder $container)
{
$propertyExtractorDefinition = $container->register(sprintf('doctrine.orm.%s_entity_manager.property_info_extractor', $entityManagerName), DoctrineExtractor::class);
if (interface_exists(PropertyInitializableExtractorInterface::class)) {
$doctrineBridgePath = dirname((new ReflectionClass(ManagerRegistry::class))->getFileName());

if (strpos(file_get_contents($doctrineBridgePath . '/CHANGELOG.md'), "4.2.0\n-----") !== false) {
$argumentId = sprintf('doctrine.orm.%s_entity_manager', $entityManagerName);
} else {
$argumentId = sprintf('doctrine.orm.%s_entity_manager.metadata_factory', $entityManagerName);
Expand Down

0 comments on commit ee7e19c

Please sign in to comment.