From 8c0b2bd5f4be2da69c422576c4a41b62efad444e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Cybula?= Date: Sat, 24 Jul 2021 17:33:09 +0200 Subject: [PATCH] Fixed compatibility with different versions of doctrine-bundle --- composer.json | 1 + .../DoctrineExtensions/Mapping/ExtendedMetadataFactory.php | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/composer.json b/composer.json index c14bb48..bf585dc 100644 --- a/composer.json +++ b/composer.json @@ -29,6 +29,7 @@ "ext-pdo_sqlite": "*", "ext-simplexml": "*", "doctrine/dbal": "^2.5", + "doctrine/doctrine-bundle": "^1.3|^2.0", "phpstan/phpstan": "^0.12.26", "phpunit/phpunit": "^7.5|^8.0", "squizlabs/php_codesniffer": "^3.4", diff --git a/lib/FSi/DoctrineExtensions/Mapping/ExtendedMetadataFactory.php b/lib/FSi/DoctrineExtensions/Mapping/ExtendedMetadataFactory.php index 73de651..247f402 100644 --- a/lib/FSi/DoctrineExtensions/Mapping/ExtendedMetadataFactory.php +++ b/lib/FSi/DoctrineExtensions/Mapping/ExtendedMetadataFactory.php @@ -11,6 +11,7 @@ namespace FSi\DoctrineExtensions\Mapping; +use Doctrine\Bundle\DoctrineBundle\Mapping\MappingDriver as DoctrineBundleMappingDriver; use Doctrine\Common\Annotations\Reader; use Doctrine\Common\Cache\Cache; use Doctrine\ORM\EntityManagerInterface; @@ -169,6 +170,9 @@ private function getDriver(MappingDriver $omDriver): DriverInterface { $className = get_class($omDriver); $driverName = substr($className, strrpos($className, '\\') + 1); + if (class_exists(DoctrineBundleMappingDriver::class) && $omDriver instanceof DoctrineBundleMappingDriver) { + $omDriver = $omDriver->getDriver(); + } if ($omDriver instanceof MappingDriverChain) { $driver = new DriverChain(); foreach ($omDriver->getDrivers() as $namespace => $nestedOmDriver) {