|
9 | 9 |
|
10 | 10 | class CompileCacheWarmer implements CacheWarmerInterface
|
11 | 11 | {
|
12 |
| - /** @var TypeGenerator */ |
13 | 12 | private $typeGenerator;
|
14 | 13 |
|
15 |
| - public function __construct(TypeGenerator $typeGenerator) |
| 14 | + private $compiled; |
| 15 | + |
| 16 | + /** |
| 17 | + * CompileCacheWarmer constructor. |
| 18 | + * |
| 19 | + * @param TypeGenerator $typeGenerator |
| 20 | + * @param bool $compiled |
| 21 | + */ |
| 22 | + public function __construct(TypeGenerator $typeGenerator, $compiled = true) |
16 | 23 | {
|
17 | 24 | $this->typeGenerator = $typeGenerator;
|
| 25 | + $this->compiled = $compiled; |
18 | 26 | }
|
19 | 27 |
|
20 | 28 | /**
|
21 | 29 | * {@inheritdoc}
|
22 | 30 | */
|
23 | 31 | public function isOptional()
|
24 | 32 | {
|
25 |
| - return false; |
| 33 | + return !$this->compiled; |
26 | 34 | }
|
27 | 35 |
|
28 | 36 | /**
|
29 | 37 | * {@inheritdoc}
|
30 | 38 | */
|
31 | 39 | public function warmUp($cacheDir): void
|
32 | 40 | {
|
33 |
| - // use warm up cache dir if type generator cache dir not already explicitly declare |
34 |
| - $baseCacheDir = $this->typeGenerator->getBaseCacheDir(); |
35 |
| - if (null === $this->typeGenerator->getCacheDir(false)) { |
36 |
| - $this->typeGenerator->setBaseCacheDir($cacheDir); |
| 41 | + if ($this->compiled) { |
| 42 | + // use warm up cache dir if type generator cache dir not already explicitly declare |
| 43 | + $baseCacheDir = $this->typeGenerator->getBaseCacheDir(); |
| 44 | + if (null === $this->typeGenerator->getCacheDir(false)) { |
| 45 | + $this->typeGenerator->setBaseCacheDir($cacheDir); |
| 46 | + } |
| 47 | + $this->typeGenerator->compile(TypeGenerator::MODE_WRITE | TypeGenerator::MODE_OVERRIDE); |
| 48 | + $this->typeGenerator->setBaseCacheDir($baseCacheDir); |
37 | 49 | }
|
38 |
| - $this->typeGenerator->compile(TypeGenerator::MODE_WRITE | TypeGenerator::MODE_OVERRIDE); |
39 |
| - $this->typeGenerator->setBaseCacheDir($baseCacheDir); |
40 | 50 | }
|
41 | 51 | }
|
0 commit comments