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