Skip to content

Commit

Permalink
Remove call to deprecated setCacheDriver() method
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolas-grekas authored and ostrolucky committed Mar 23, 2021
1 parent eab63c2 commit 155a870
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions CacheWarmer/DoctrineMetadataCacheWarmer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 155a870

Please sign in to comment.