| 1 |
<?php |
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
namespace Symfony\Component\Serializer\CacheWarmer; |
| 13 |
|
| 14 |
use Symfony\Component\Filesystem\Filesystem; |
| 15 |
use Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerInterface; |
| 16 |
use Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactoryCompiler; |
| 17 |
use Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactoryInterface; |
| 18 |
|
| 19 |
trigger_deprecation('symfony/serializer', '7.3', 'The "%s" class is deprecated.', CompiledClassMetadataCacheWarmer::class); |
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
final class CompiledClassMetadataCacheWarmer implements CacheWarmerInterface |
| 27 |
{ |
| 28 |
public function __construct( |
| 29 |
private readonly array $classesToCompile, |
| 30 |
private readonly ClassMetadataFactoryInterface $classMetadataFactory, |
| 31 |
private readonly ClassMetadataFactoryCompiler $classMetadataFactoryCompiler, |
| 32 |
private readonly Filesystem $filesystem, |
| 33 |
) { |
| 34 |
} |
| 35 |
|
| 36 |
public function warmUp(string $cacheDir, ?string $buildDir = null): array |
| 37 |
{ |
| 38 |
$metadatas = []; |
| 39 |
|
| 40 |
foreach ($this->classesToCompile as $classToCompile) { |
| 41 |
$metadatas[] = $this->classMetadataFactory->getMetadataFor($classToCompile); |
| 42 |
} |
| 43 |
|
| 44 |
$code = $this->classMetadataFactoryCompiler->compile($metadatas); |
| 45 |
|
| 46 |
$this->filesystem->dumpFile("{$cacheDir}/serializer.class.metadata.php", $code); |
| 47 |
|
| 48 |
return []; |
| 49 |
} |
| 50 |
|
| 51 |
public function isOptional(): bool |
| 52 |
{ |
| 53 |
return true; |
| 54 |
} |
| 55 |
} |