Skip to content

Commit c3dc9dc

Browse files
author
Iltar van der Berg
committed
Added build and class cache to kernel
1 parent 43e4add commit c3dc9dc

File tree

3 files changed

+56
-0
lines changed

3 files changed

+56
-0
lines changed

Kernel.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,17 @@ protected function initializeBundles()
466466
}
467467
}
468468

469+
/**
470+
* The extension point similar to the Bundle::build() method.
471+
*
472+
* Use this method to register compiler passes and manipulate the container during the building process.
473+
*
474+
* @param ContainerBuilder $container
475+
*/
476+
protected function build(ContainerBuilder $container)
477+
{
478+
}
479+
469480
/**
470481
* Gets the container class.
471482
*
@@ -625,10 +636,13 @@ protected function prepareContainer(ContainerBuilder $container)
625636
$container->addObjectResource($bundle);
626637
}
627638
}
639+
628640
foreach ($this->bundles as $bundle) {
629641
$bundle->build($container);
630642
}
631643

644+
$this->build($container);
645+
632646
// ensure these extensions are implicitly loaded
633647
$container->getCompilerPassConfig()->setMergePass(new MergeExtensionConfigurationPass($extensions));
634648
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\HttpKernel\Tests\Fixtures;
13+
14+
use Symfony\Component\Config\Loader\LoaderInterface;
15+
use Symfony\Component\DependencyInjection\ContainerBuilder;
16+
use Symfony\Component\HttpKernel\Kernel;
17+
18+
class KernelWithoutBundles extends Kernel
19+
{
20+
public function registerBundles()
21+
{
22+
return array();
23+
}
24+
25+
public function registerContainerConfiguration(LoaderInterface $loader)
26+
{
27+
}
28+
29+
protected function build(ContainerBuilder $container)
30+
{
31+
$container->setParameter('test_executed', true);
32+
}
33+
}

Tests/KernelTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
use Symfony\Component\HttpFoundation\Response;
2222
use Symfony\Component\HttpKernel\Tests\Fixtures\KernelForTest;
2323
use Symfony\Component\HttpKernel\Tests\Fixtures\KernelForOverrideName;
24+
use Symfony\Component\HttpKernel\Tests\Fixtures\KernelWithoutBundles;
2425

2526
class KernelTest extends TestCase
2627
{
@@ -725,6 +726,14 @@ public function testTerminateDelegatesTerminationOnlyForTerminableInterface()
725726
$kernel->terminate(Request::create('/'), new Response());
726727
}
727728

729+
public function testKernelWithoutBundles()
730+
{
731+
$kernel = new KernelWithoutBundles('test', true);
732+
$kernel->boot();
733+
734+
$this->assertTrue($kernel->getContainer()->getParameter('test_executed'));
735+
}
736+
728737
/**
729738
* Returns a mock for the BundleInterface.
730739
*

0 commit comments

Comments
 (0)