Skip to content

Commit 52688b4

Browse files
Add hacky fix for Doctrine Bundle 2.3 (#2211)
* Add hacky fix for Doctrine Bundle 2.3 * Fix reflection access for private property Co-authored-by: Alexander Schranz <[email protected]> * Add changelog entry for #2211 Co-authored-by: Alexander Schranz <[email protected]>
1 parent 7c0d5ae commit 52688b4

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ a release.
1919
---
2020

2121
## [Unreleased]
22+
### Fixed
23+
- Add hacky measure to resolve incompatibility with DoctrineBundle 2.3 [#2211](https://github.com/doctrine-extensions/DoctrineExtensions/pull/2211)
2224

2325
## [3.0.3] - 2021-01-23
2426
### Fixed

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
},
4848
"require-dev": {
4949
"alcaeus/mongo-php-adapter": "^1.1",
50+
"doctrine/doctrine-bundle": "^2.3",
5051
"doctrine/mongodb-odm": "^2.0",
5152
"doctrine/orm": "^2.6.3",
5253
"friendsofphp/php-cs-fixer": "^2.16",

src/Mapping/ExtensionMetadataFactory.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Gedmo\Mapping;
44

5+
use Doctrine\Bundle\DoctrineBundle\Mapping\MappingDriver as DoctrineBundleMappingDriver;
56
use Doctrine\Common\Cache\Cache;
67
use Doctrine\Persistence\Mapping\Driver\DefaultFileLocator;
78
use Doctrine\Persistence\Mapping\Driver\MappingDriver;
@@ -137,6 +138,13 @@ public static function getCacheId($className, $extensionNamespace)
137138
*/
138139
protected function getDriver($omDriver)
139140
{
141+
if ($omDriver instanceof DoctrineBundleMappingDriver) {
142+
$propertyReflection = (new \ReflectionClass($omDriver))
143+
->getProperty('driver');
144+
$propertyReflection->setAccessible(true);
145+
$omDriver = $propertyReflection->getValue($omDriver);
146+
}
147+
140148
$driver = null;
141149
$className = get_class($omDriver);
142150
$driverName = substr($className, strrpos($className, '\\') + 1);

0 commit comments

Comments
 (0)