From 757194c775c1efe4bdad74143989c5f3f705a723 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Wed, 20 Mar 2013 14:53:56 +0100 Subject: [PATCH] [HttpKernel] made the Kernel class more flexible (closes #7396) --- src/Symfony/Component/HttpKernel/Kernel.php | 31 +++++++++++++-------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/src/Symfony/Component/HttpKernel/Kernel.php b/src/Symfony/Component/HttpKernel/Kernel.php index b2e05ae3cb6a..e743cfd3a151 100644 --- a/src/Symfony/Component/HttpKernel/Kernel.php +++ b/src/Symfony/Component/HttpKernel/Kernel.php @@ -636,6 +636,26 @@ protected function buildContainer() } $container = $this->getContainerBuilder(); + $container->addObjectResource($this); + $this->prepareContainer($container); + + if (null !== $cont = $this->registerContainerConfiguration($this->getContainerLoader($container))) { + $container->merge($cont); + } + + $container->addCompilerPass(new AddClassesToCachePass($this)); + $container->compile(); + + return $container; + } + + /** + * Prepares the ContainerBuilder before it is compiled. + * + * @param ContainerBuilder $container A ContainerBuilder instance + */ + protected function prepareContainer(ContainerBuilder $container) + { $extensions = array(); foreach ($this->bundles as $bundle) { if ($extension = $bundle->getContainerExtension()) { @@ -651,19 +671,8 @@ protected function buildContainer() $bundle->build($container); } - $container->addObjectResource($this); - // ensure these extensions are implicitly loaded $container->getCompilerPassConfig()->setMergePass(new MergeExtensionConfigurationPass($extensions)); - - if (null !== $cont = $this->registerContainerConfiguration($this->getContainerLoader($container))) { - $container->merge($cont); - } - - $container->addCompilerPass(new AddClassesToCachePass($this)); - $container->compile(); - - return $container; } /**