Symfony\Component\HttpKernel\Kernel::dumpContainer PHP Method

dumpContainer() protected method

Dumps the service container to PHP code in the cache.
protected dumpContainer ( Symfony\Component\Config\ConfigCache $cache, ContainerBuilder $container, string $class, string $baseClass )
$cache Symfony\Component\Config\ConfigCache The config cache
$container Symfony\Component\DependencyInjection\ContainerBuilder The service container
$class string The name of the class to generate
$baseClass string The name of the container's base class
    protected function dumpContainer(ConfigCache $cache, ContainerBuilder $container, $class, $baseClass)
    {
        // cache the container
        $dumper = new PhpDumper($container);
        $content = $dumper->dump(array('class' => $class, 'base_class' => $baseClass));
        if (!$this->debug) {
            $content = self::stripComments($content);
        }

        $cache->write($content, $container->getResources());
    }

Usage Example

 protected function dumpContainer(ConfigCache $cache, ContainerBuilder $container, $class, $baseClass)
 {
     parent::dumpContainer($cache, $container, $class, $baseClass);
     $data = array();
     foreach ($this->zikulaBundles as $type => $bundles) {
         /* @var AbstractModule $bundle */
         foreach ($bundles as $bundle) {
             $data[$bundle->getName()] = $bundle->getServiceIds();
         }
     }
     $cache = new \Symfony\Component\Config\ConfigCache($this->getCacheDir() . '/' . $class . '.modules', $this->debug);
     $cache->write(serialize($data));
 }
All Usage Examples Of Symfony\Component\HttpKernel\Kernel::dumpContainer