diff --git a/src/Symfony/Component/HttpKernel/Kernel.php b/src/Symfony/Component/HttpKernel/Kernel.php index 9523b7a3ca997..b8c4e177ee3b9 100644 --- a/src/Symfony/Component/HttpKernel/Kernel.php +++ b/src/Symfony/Component/HttpKernel/Kernel.php @@ -466,6 +466,17 @@ protected function initializeBundles() } } + /** + * The extension point similar to the Bundle::build() method. + * + * Use this method to register compiler passes and manipulate the container during the building process. + * + * @param ContainerBuilder $container + */ + protected function build(ContainerBuilder $container) + { + } + /** * Gets the container class. * @@ -625,10 +636,13 @@ protected function prepareContainer(ContainerBuilder $container) $container->addObjectResource($bundle); } } + foreach ($this->bundles as $bundle) { $bundle->build($container); } + $this->build($container); + // ensure these extensions are implicitly loaded $container->getCompilerPassConfig()->setMergePass(new MergeExtensionConfigurationPass($extensions)); } diff --git a/src/Symfony/Component/HttpKernel/Tests/Fixtures/KernelWithoutBundles.php b/src/Symfony/Component/HttpKernel/Tests/Fixtures/KernelWithoutBundles.php new file mode 100644 index 0000000000000..cee1b09fb2253 --- /dev/null +++ b/src/Symfony/Component/HttpKernel/Tests/Fixtures/KernelWithoutBundles.php @@ -0,0 +1,33 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\HttpKernel\Tests\Fixtures; + +use Symfony\Component\Config\Loader\LoaderInterface; +use Symfony\Component\DependencyInjection\ContainerBuilder; +use Symfony\Component\HttpKernel\Kernel; + +class KernelWithoutBundles extends Kernel +{ + public function registerBundles() + { + return array(); + } + + public function registerContainerConfiguration(LoaderInterface $loader) + { + } + + protected function build(ContainerBuilder $container) + { + $container->setParameter('test_executed', true); + } +} diff --git a/src/Symfony/Component/HttpKernel/Tests/KernelTest.php b/src/Symfony/Component/HttpKernel/Tests/KernelTest.php index e7b4bc98593ac..7e77903c5de4c 100644 --- a/src/Symfony/Component/HttpKernel/Tests/KernelTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/KernelTest.php @@ -21,6 +21,7 @@ use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Tests\Fixtures\KernelForTest; use Symfony\Component\HttpKernel\Tests\Fixtures\KernelForOverrideName; +use Symfony\Component\HttpKernel\Tests\Fixtures\KernelWithoutBundles; class KernelTest extends TestCase { @@ -725,6 +726,14 @@ public function testTerminateDelegatesTerminationOnlyForTerminableInterface() $kernel->terminate(Request::create('/'), new Response()); } + public function testKernelWithoutBundles() + { + $kernel = new KernelWithoutBundles('test', true); + $kernel->boot(); + + $this->assertTrue($kernel->getContainer()->getParameter('test_executed')); + } + /** * Returns a mock for the BundleInterface. *