From 155a870ecbd035963e6b450e0f235e69c48cab30 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Mon, 22 Mar 2021 14:38:45 +0100 Subject: [PATCH] Remove call to deprecated setCacheDriver() method --- CacheWarmer/DoctrineMetadataCacheWarmer.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/CacheWarmer/DoctrineMetadataCacheWarmer.php b/CacheWarmer/DoctrineMetadataCacheWarmer.php index e57594306..b2ce43b3f 100644 --- a/CacheWarmer/DoctrineMetadataCacheWarmer.php +++ b/CacheWarmer/DoctrineMetadataCacheWarmer.php @@ -6,7 +6,8 @@ use LogicException; use Symfony\Bundle\FrameworkBundle\CacheWarmer\AbstractPhpFileCacheWarmer; use Symfony\Component\Cache\Adapter\ArrayAdapter; -use Symfony\Component\Cache\DoctrineProvider; + +use function method_exists; class DoctrineMetadataCacheWarmer extends AbstractPhpFileCacheWarmer { @@ -47,7 +48,13 @@ protected function doWarmUp($cacheDir, ArrayAdapter $arrayAdapter): bool throw new LogicException('DoctrineMetadataCacheWarmer must load metadata first, check priority of your warmers.'); } - $metadataFactory->setCacheDriver(new DoctrineProvider($arrayAdapter)); + if (method_exists($metadataFactory, 'setCache')) { + $metadataFactory->setCache($arrayAdapter); + } else { + // BC with doctrine/persistence < 2.2 + $metadataFactory->setCacheDriver(new DoctrineProvider($arrayAdapter)); + } + $metadataFactory->getAllMetadata(); return true;