function Kernel::dumpContainer
Dumps the service container to PHP code in the cache.
Parameters
string $class The name of the class to generate:
string $baseClass The name of the container's base class:
1 call to Kernel::dumpContainer()
- Kernel::initializeContainer in vendor/
symfony/ http-kernel/ Kernel.php - Initializes the service container.
File
-
vendor/
symfony/ http-kernel/ Kernel.php, line 669
Class
- Kernel
- The Kernel is the heart of the Symfony system.
Namespace
Symfony\Component\HttpKernelCode
protected function dumpContainer(ConfigCache $cache, ContainerBuilder $container, string $class, string $baseClass) : void {
// cache the container
$dumper = new PhpDumper($container);
$buildParameters = [];
foreach ($container->getCompilerPassConfig()
->getPasses() as $pass) {
if ($pass instanceof RemoveBuildParametersPass) {
$buildParameters = array_merge($buildParameters, $pass->getRemovedParameters());
}
}
$content = $dumper->dump([
'class' => $class,
'base_class' => $baseClass,
'file' => $cache->getPath(),
'as_files' => true,
'debug' => $this->debug,
'inline_factories' => $buildParameters['.container.dumper.inline_factories'] ?? false,
'inline_class_loader' => $buildParameters['.container.dumper.inline_class_loader'] ?? $this->debug,
'build_time' => $container->hasParameter('kernel.container_build_time') ? $container->getParameter('kernel.container_build_time') : time(),
'preload_classes' => array_map('get_class', $this->bundles),
]);
$rootCode = array_pop($content);
$dir = \dirname($cache->getPath()) . '/';
$fs = new Filesystem();
foreach ($content as $file => $code) {
$fs->dumpFile($dir . $file, $code);
@chmod($dir . $file, 0666 & ~umask());
}
$legacyFile = \dirname($dir . key($content)) . '.legacy';
if (is_file($legacyFile)) {
@unlink($legacyFile);
}
$cache->write($rootCode, $container->getResources());
}