@@ -644,7 +644,9 @@ protected function initializeContainer()
644
644
}
645
645
}
646
646
647
- if (null === $ oldContainer && file_exists ($ cache ->getPath ())) {
647
+ $ asFiles = true ;
648
+
649
+ if ($ asFiles && null === $ oldContainer && file_exists ($ cache ->getPath ())) {
648
650
$ errorLevel = error_reporting (\E_ALL ^ \E_WARNING );
649
651
try {
650
652
$ oldContainer = include $ cache ->getPath ();
@@ -655,8 +657,7 @@ protected function initializeContainer()
655
657
}
656
658
}
657
659
$ oldContainer = \is_object ($ oldContainer ) ? new \ReflectionClass ($ oldContainer ) : false ;
658
-
659
- $ this ->dumpContainer ($ cache , $ container , $ class , $ this ->getContainerBaseClass ());
660
+ $ this ->dumpContainer ($ cache , $ container , $ class , $ this ->getContainerBaseClass (), $ asFiles );
660
661
$ this ->container = require $ cache ->getPath ();
661
662
$ this ->container ->set ('kernel ' , $ this );
662
663
@@ -835,7 +836,7 @@ protected function getContainerBuilder()
835
836
* @param string $class The name of the class to generate
836
837
* @param string $baseClass The name of the container's base class
837
838
*/
838
- protected function dumpContainer (ConfigCache $ cache , ContainerBuilder $ container , $ class , $ baseClass )
839
+ protected function dumpContainer (ConfigCache $ cache , ContainerBuilder $ container , $ class , $ baseClass, bool $ asFiles = true )
839
840
{
840
841
// cache the container
841
842
$ dumper = new PhpDumper ($ container );
@@ -848,23 +849,28 @@ protected function dumpContainer(ConfigCache $cache, ContainerBuilder $container
848
849
'class ' => $ class ,
849
850
'base_class ' => $ baseClass ,
850
851
'file ' => $ cache ->getPath (),
851
- 'as_files ' => true ,
852
+ 'as_files ' => $ asFiles ,
852
853
'debug ' => $ this ->debug ,
853
854
'inline_class_loader_parameter ' => \PHP_VERSION_ID >= 70000 && !$ this ->loadClassCache && !class_exists (
8000
ClassCollectionLoader::class, false ) ? 'container.dumper.inline_class_loader ' : null ,
854
855
'build_time ' => $ container ->hasParameter ('kernel.container_build_time ' ) ? $ container ->getParameter ('kernel.container_build_time ' ) : time (),
855
856
]);
856
857
857
- $ rootCode = array_pop ($ content );
858
- $ dir = \dirname ($ cache ->getPath ()).'/ ' ;
859
858
$ fs = new Filesystem ();
860
859
861
- foreach ($ content as $ file => $ code ) {
862
- $ fs ->dumpFile ($ dir .$ file , $ code );
863
- @chmod ($ dir .$ file , 0666 & ~umask ());
864
- }
865
- $ legacyFile = \dirname ($ dir .$ file ).'.legacy ' ;
866
- if (file_exists ($ legacyFile )) {
867
- @unlink ($ legacyFile );
860
+ if (\is_array ($ content )) {
861
+ $ rootCode = array_pop ($ content );
862
+ $ dir = \dirname ($ cache ->getPath ()).'/ ' ;
863
+
864
+ foreach ($ content as $ file => $ code ) {
865
+ $ fs ->dumpFile ($ dir .$ file , $ code );
866
+ @chmod ($ dir .$ file , 0666 & ~umask ());
867
+ }
868
+ $ legacyFile = \dirname ($ dir .$ file ).'.legacy ' ;
869
+ if (file_exists ($ legacyFile )) {
870
+ @unlink ($ legacyFile );
871
+ }
872
+ } else {
873
+ $ rootCode = $ content ;
868
874
}
869
875
870
876
$ cache ->write ($ rootCode , $ container ->getResources ());
0 commit comments