init
This commit is contained in:
49
backend/vendor/doctrine/doctrine-bundle/src/CacheWarmer/DoctrineMetadataCacheWarmer.php
vendored
Normal file
49
backend/vendor/doctrine/doctrine-bundle/src/CacheWarmer/DoctrineMetadataCacheWarmer.php
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\Bundle\DoctrineBundle\CacheWarmer;
|
||||
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use LogicException;
|
||||
use Symfony\Bundle\FrameworkBundle\CacheWarmer\AbstractPhpFileCacheWarmer;
|
||||
use Symfony\Component\Cache\Adapter\ArrayAdapter;
|
||||
|
||||
use function is_file;
|
||||
|
||||
/** @final since 2.11 */
|
||||
class DoctrineMetadataCacheWarmer extends AbstractPhpFileCacheWarmer
|
||||
{
|
||||
public function __construct(
|
||||
private readonly EntityManagerInterface $entityManager,
|
||||
private readonly string $phpArrayFile,
|
||||
) {
|
||||
parent::__construct($phpArrayFile);
|
||||
}
|
||||
|
||||
/**
|
||||
* It must not be optional because it should be called before ProxyCacheWarmer which is not optional.
|
||||
*/
|
||||
public function isOptional(): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
protected function doWarmUp(string $cacheDir, ArrayAdapter $arrayAdapter, string|null $buildDir = null): bool
|
||||
{
|
||||
// cache already warmed up, no needs to do it again
|
||||
if (is_file($this->phpArrayFile)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$metadataFactory = $this->entityManager->getMetadataFactory();
|
||||
if ($metadataFactory->getLoadedMetadata()) {
|
||||
throw new LogicException('DoctrineMetadataCacheWarmer must load metadata first, check priority of your warmers.');
|
||||
}
|
||||
|
||||
$metadataFactory->setCache($arrayAdapter);
|
||||
$metadataFactory->getAllMetadata();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user