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

fix Doctrine bridge version detection #918

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 5 additions & 2 deletions DependencyInjection/DoctrineExtension.php
Expand Up @@ -9,8 +9,10 @@
use Doctrine\Common\Persistence\Mapping\ClassMetadataFactory;
use Doctrine\ORM\Version;
use LogicException;
use ReflectionClass;
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 +27,6 @@
use Symfony\Component\DependencyInjection\ServiceLocator;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Messenger\MessageBusInterface;
use Symfony\Component\PropertyInfo\PropertyInitializableExtractorInterface;

/**
* 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