@@ -314,7 +314,7 @@ public function getContainer()
314
314
*/
315
315
public function setAnnotatedClassCache (array $ annotatedClasses )
316
316
{
317
- file_put_contents (($ this ->warmupDir ?: $ this ->getCacheDir ()).'/annotations.map ' , sprintf ('<?php return %s; ' , var_export ($ annotatedClasses , true )));
317
+ file_put_contents (($ this ->warmupDir ?: $ this ->getBuildDir ()).'/annotations.map ' , sprintf ('<?php return %s; ' , var_export ($ annotatedClasses , true )));
318
318
}
319
319
320
320
/**
@@ -333,6 +333,15 @@ public function getCacheDir()
333
333
return $ this ->getProjectDir ().'/var/cache/ ' .$ this ->environment ;
334
334
}
335
335
336
+ /**
337
+ * Gets the build directory.
338
+ */
339
+ public function getBuildDir (): string
340
+ {
341
+ // Returns $this->getCacheDir() for backward compatibility
342
+ return $ this ->getCacheDir ();
343
+ }
344
+
336
345
/**
337
346
* {@inheritdoc}
338
347
*/
@@ -419,14 +428,14 @@ protected function getContainerBaseClass()
419
428
/**
420
429
* Initializes the service container.
421
430
*
422
- * The cached version of the service container is used when fresh, otherwise the
431
+ * The built version of the service container is used when fresh, otherwise the
423
432
* container is built.
424
433
*/
425
434
protected function initializeContainer ()
426
435
{
427
436
$ class = $ this ->getContainerClass ();
428
- $ cacheDir = $ this ->warmupDir ?: $ this ->getCacheDir ();
429
- $ cache = new ConfigCache ($ cacheDir .'/ ' .$ class .'.php ' , $ this ->debug );
437
+ $ buildDir = $ this ->warmupDir ?: $ this ->getBuildDir ();
438
+ $ cache = new ConfigCache ($ buildDir .'/ ' .$ class .'.php ' , $ this ->debug );
430
439
$ cachePath = $ cache ->getPath ();
431
440
432
441
// Silence E_WARNING to ignore "include" failures - don't use "@" to prevent silencing fatal errors
@@ -448,7 +457,7 @@ protected function initializeContainer()
448
457
$ oldContainer = \is_object ($ this ->container ) ? new \ReflectionClass ($ this ->container ) : $ this ->container = null ;
449
458
450
459
try {
451
- is_dir ($ cacheDir ) ?: mkdir ($ cacheDir , 0777 , true );
460
+ is_dir ($ buildDir ) ?: mkdir ($ buildDir , 0777 , true );
452
461
453
462
if ($ lock = fopen ($ cachePath .'.lock ' , 'w ' )) {
454
463
flock ($ lock , LOCK_EX | LOCK_NB , $ wouldBlock );
@@ -533,8 +542,8 @@ protected function initializeContainer()
533
542
if ($ collectDeprecations ) {
534
543
restore_error_handler ();
535
544
536
- file_put_contents ($ cacheDir .'/ ' .$ class .'Deprecations.log ' , serialize (array_values ($ collectedLogs )));
537
- file_put_contents ($ cacheDir .'/ ' .$ class .'Compiler.log ' , null !== $ container ? implode ("\n" , $ container ->getCompiler ()->getLog ()) : '' );
545
+ file_put_contents ($ buildDir .'/ ' .$ class .'Deprecations.log ' , serialize (array_values ($ collectedLogs )));
546
+ file_put_contents ($ buildDir .'/ ' .$ class .'Compiler.log ' , null !== $ container ? implode ("\n" , $ container ->getCompiler ()->getLog ()) : '' );
538
547
}
539
548
}
540
549
@@ -570,7 +579,7 @@ protected function initializeContainer()
570
579
$ preload = array_merge ($ preload , (array ) $ this ->container ->get ('cache_warmer ' )->warmUp ($ this ->container ->getParameter ('kernel.cache_dir ' )));
571
580
}
572
581
573
- if ($ preload && method_exists (Preloader::class, 'append ' ) && file_exists ($ preloadFile = $ cacheDir .'/ ' .$ class .'.preload.php ' )) {
582
+ if ($ preload && method_exists (Preloader::class, 'append ' ) && file_exists ($ preloadFile = $ buildDir .'/ ' .$ class .'.preload.php ' )) {
574
583
Preloader::append ($ preloadFile , $ preload );
575
584
}
576
585
}
@@ -597,7 +606,8 @@ protected function getKernelParameters()
597
606
'kernel.project_dir ' => realpath ($ this ->getProjectDir ()) ?: $ this ->getProjectDir (),
598
607
'kernel.environment ' => $ this ->environment ,
599
608
'kernel.debug ' => $ this ->debug ,
600
- 'kernel.cache_dir ' => realpath ($ cacheDir = $ this ->warmupDir ?: $ this ->getCacheDir ()) ?: $ cacheDir ,
609
+ 'kernel.build_dir ' => realpath ($ buildDir = $ this ->warmupDir ?: $ this ->getBuildDir ()) ?: $ buildDir ,
610
+ 'kernel.cache_dir ' => realpath ($ this ->getCacheDir ()) ?: $ this ->getCacheDir (),
601
611
'kernel.logs_dir ' => realpath ($ this ->getLogDir ()) ?: $ this ->getLogDir (),
602
612
'kernel.bundles ' => $ bundles ,
603
613
'kernel.bundles_metadata ' => $ bundlesMetadata ,
@@ -615,7 +625,7 @@ protected function getKernelParameters()
615
625
*/
616
626
protected function buildContainer ()
617
627
{
618
- foreach (['cache ' => $ this ->warmupDir ?: $ this ->getCacheDir (), 'logs ' => $ this ->getLogDir ()] as $ name => $ dir ) {
628
+ foreach (['cache ' => $ this ->getCacheDir (), ' build ' => $ this -> warmupDir ?: $ this ->getBuildDir (), 'logs ' => $ this ->getLogDir ()] as $ name => $ dir ) {
619
629
if (!is_dir ($ dir )) {
620
630
if (false === @mkdir ($ dir , 0777 , true ) && !is_dir ($ dir )) {
621
631
throw new \RuntimeException (sprintf ('Unable to create the "%s" directory (%s). ' , $ name , $ dir ));
0 commit comments