|
13 | 13 | use Doctrine\ORM\EntityManagerInterface; |
14 | 14 | use Doctrine\ORM\Mapping\ClassMetadata as ORMClassMetadata; |
15 | 15 | use Doctrine\ORM\Mapping\ClassMetadataInfo; |
| 16 | +use Doctrine\Persistence\Mapping\AbstractClassMetadataFactory; |
16 | 17 | use Doctrine\Persistence\Mapping\ClassMetadata; |
17 | 18 | use Doctrine\Persistence\ObjectManager; |
18 | 19 | use Gedmo\Exception\RuntimeException; |
19 | 20 | use Gedmo\Mapping\Event\AdapterInterface; |
20 | 21 | use Gedmo\Tool\Wrapper\AbstractWrapper; |
21 | 22 | use Gedmo\Tree\Strategy; |
22 | 23 | use Gedmo\Tree\TreeListener; |
| 24 | +use Psr\Cache\CacheItemPoolInterface; |
23 | 25 |
|
24 | 26 | /** |
25 | 27 | * This strategy makes tree act like |
@@ -194,16 +196,21 @@ public function processMetadataLoad($em, $meta) |
194 | 196 | } |
195 | 197 |
|
196 | 198 | if (!$hasTheUserExplicitlyDefinedMapping) { |
197 | | - $cacheDriver = $em->getConfiguration()->getMetadataCache(); |
| 199 | + $metadataFactory = $em->getMetadataFactory(); |
| 200 | + $getCache = \Closure::bind(static function (AbstractClassMetadataFactory $metadataFactory): ?CacheItemPoolInterface { |
| 201 | + return $metadataFactory->getCache(); |
| 202 | + }, null, \get_class($metadataFactory)); |
198 | 203 |
|
199 | | - if (null !== $cacheDriver) { |
| 204 | + $metadataCache = $getCache($metadataFactory); |
| 205 | + |
| 206 | + if (null !== $metadataCache) { |
200 | 207 | // @see https://github.com/doctrine/persistence/pull/144 |
201 | 208 | // @see \Doctrine\Persistence\Mapping\AbstractClassMetadataFactory::getCacheKey() |
202 | 209 | $cacheKey = str_replace('\\', '__', $closureMetadata->getName()).'__CLASSMETADATA__'; |
203 | 210 |
|
204 | | - $item = $cacheDriver->getItem($cacheKey); |
| 211 | + $item = $metadataCache->getItem($cacheKey); |
205 | 212 |
|
206 | | - $cacheDriver->save($item->set($closureMetadata)); |
| 213 | + $metadataCache->save($item->set($closureMetadata)); |
207 | 214 | } |
208 | 215 | } |
209 | 216 | } |
|
0 commit comments