Debian Codegraph @

lib/3rdParty/composer/symfony/serializer/CacheWarmer/CompiledClassMetadataCacheWarmer.php

raw symbols SCIP
1 <?php
2
3 /*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <[email protected]>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
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 * @author Fabien Bourigault <[email protected]>
23 *
24 * @deprecated since Symfony 7.3
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 }