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 29bc743
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion 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 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 (false !== strpos(file_get_contents($doctrineBridgePath.'/CHANGELOG.md'), "4.2.0\n-----")) {
$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 29bc743

Please sign in to comment.