Skip to content

Commit dcaf436

Browse files
committed
updated the framework to take into account the last changes of the DI component
1 parent 60c6827 commit dcaf436

File tree

4 files changed

+30
-17
lines changed

4 files changed

+30
-17
lines changed

src/Symfony/Bundle/FrameworkBundle/Resources/skeleton/application/xml/Kernel.php

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
require_once __DIR__.'/../src/autoload.php';
44

55
use Symfony\Framework\Kernel;
6-
use Symfony\Components\DependencyInjection\Loader\XmlFileLoader as ContainerLoader;
7-
use Symfony\Components\DependencyInjection\ContainerBuilder;
6+
use Symfony\Components\DependencyInjection\Loader\LoaderInterface;
87

98
use Symfony\Framework\Bundle\KernelBundle;
109
use Symfony\Bundle\FrameworkBundle\FrameworkBundle;
@@ -48,12 +47,8 @@ public function registerBundleDirs()
4847
);
4948
}
5049

51-
public function registerContainerConfiguration()
50+
public function registerContainerConfiguration(LoaderInterface $loader)
5251
{
53-
$container = new ContainerBuilder();
54-
$loader = new ContainerLoader($container, $this->getBundleDirs());
5552
$loader->load(__DIR__.'/config/config_'.$this->getEnvironment().'.xml');
56-
57-
return $container;
5853
}
5954
}

src/Symfony/Bundle/FrameworkBundle/Resources/skeleton/application/yaml/Kernel.php

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
require_once __DIR__.'/../src/autoload.php';
44

55
use Symfony\Framework\Kernel;
6-
use Symfony\Components\DependencyInjection\Loader\YamlFileLoader as ContainerLoader;
7-
use Symfony\Components\DependencyInjection\ContainerBuilder;
6+
use Symfony\Components\DependencyInjection\Loader\LoaderInterface;
87

98
use Symfony\Framework\Bundle\KernelBundle;
109
use Symfony\Bundle\FrameworkBundle\FrameworkBundle;
@@ -48,12 +47,8 @@ public function registerBundleDirs()
4847
);
4948
}
5049

51-
public function registerContainerConfiguration()
50+
public function registerContainerConfiguration(LoaderInterface $loader)
5251
{
53-
$container = new ContainerBuilder();
54-
$loader = new ContainerLoader($container, $this->getBundleDirs());
5552
$loader->load(__DIR__.'/config/config_'.$this->getEnvironment().'.yml');
56-
57-
return $container;
5853
}
5954
}

src/Symfony/Framework/Kernel.php

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@
77
use Symfony\Components\DependencyInjection\Dumper\PhpDumper;
88
use Symfony\Components\DependencyInjection\Resource\FileResource;
99
use Symfony\Components\DependencyInjection\ParameterBag\ParameterBag;
10+
use Symfony\Components\DependencyInjection\Loader\DelegatingLoader;
11+
use Symfony\Components\DependencyInjection\Loader\LoaderResolver;
12+
use Symfony\Components\DependencyInjection\Loader\LoaderInterface;
13+
use Symfony\Components\DependencyInjection\Loader\XmlFileLoader;
14+
use Symfony\Components\DependencyInjection\Loader\YamlFileLoader;
15+
use Symfony\Components\DependencyInjection\Loader\IniFileLoader;
16+
use Symfony\Components\DependencyInjection\Loader\PhpFileLoader;
1017
use Symfony\Components\HttpFoundation\Request;
1118
use Symfony\Components\HttpKernel\HttpKernelInterface;
1219

@@ -83,7 +90,7 @@ abstract public function registerBundles();
8390

8491
abstract public function registerBundleDirs();
8592

86-
abstract public function registerContainerConfiguration();
93+
abstract public function registerContainerConfiguration(LoaderInterface $loader);
8794

8895
/**
8996
* Checks whether the current kernel has been booted or not.
@@ -347,7 +354,10 @@ protected function buildContainer($class, $file)
347354
$container->addObjectResource($bundle);
348355
}
349356
}
350-
$container->merge($this->registerContainerConfiguration());
357+
358+
if (null !== $cont = $this->registerContainerConfiguration($this->getContainerLoader($container))) {
359+
$container->merge($cont);
360+
}
351361
$container->freeze();
352362

353363
foreach (array('cache', 'logs') as $name) {
@@ -377,6 +387,18 @@ protected function buildContainer($class, $file)
377387
}
378388
}
379389

390+
protected function getContainerLoader(ContainerInterface $container)
391+
{
392+
$resolver = new LoaderResolver(array(
393+
new XmlFileLoader($container, $this->getBundleDirs()),
394+
new YamlFileLoader($container, $this->getBundleDirs()),
395+
new IniFileLoader($container, $this->getBundleDirs()),
396+
new PhpFileLoader($container, $this->getBundleDirs()),
397+
));
398+
399+
return new DelegatingLoader($resolver);
400+
}
401+
380402
static public function stripComments($source)
381403
{
382404
if (!function_exists('token_get_all')) {

tests/Symfony/Tests/Framework/KernelTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Tests\Framework;
1313

1414
use Symfony\Framework\Kernel;
15+
use Symfony\Components\DependencyInjection\Loader\LoaderInterface;
1516

1617
class KernelTest extends \PHPUnit_Framework_TestCase
1718
{
@@ -44,7 +45,7 @@ public function registerBundleDirs()
4445
{
4546
}
4647

47-
public function registerContainerConfiguration()
48+
public function registerContainerConfiguration(LoaderInterface $loader)
4849
{
4950
}
5051

0 commit comments

Comments
 (0)