|
0
|
1 |
<?php |
|
|
2 |
|
|
|
3 |
/* |
|
|
4 |
* This file is part of the Symfony package. |
|
|
5 |
* |
|
|
6 |
* (c) Fabien Potencier <fabien@symfony.com> |
|
|
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\DependencyInjection\Compiler; |
|
|
13 |
|
|
|
14 |
use Symfony\Component\DependencyInjection\ContainerBuilder; |
|
|
15 |
|
|
|
16 |
/** |
|
|
17 |
* Merges extension configs into the container builder |
|
|
18 |
* |
|
|
19 |
* @author Fabien Potencier <fabien@symfony.com> |
|
|
20 |
*/ |
|
|
21 |
class MergeExtensionConfigurationPass implements CompilerPassInterface |
|
|
22 |
{ |
|
|
23 |
/** |
|
|
24 |
* {@inheritDoc} |
|
|
25 |
*/ |
|
|
26 |
public function process(ContainerBuilder $container) |
|
|
27 |
{ |
|
|
28 |
$parameters = $container->getParameterBag()->all(); |
|
|
29 |
$definitions = $container->getDefinitions(); |
|
|
30 |
$aliases = $container->getAliases(); |
|
|
31 |
|
|
|
32 |
foreach ($container->getExtensions() as $name => $extension) { |
|
|
33 |
if (!$config = $container->getExtensionConfig($name)) { |
|
|
34 |
// this extension was not called |
|
|
35 |
continue; |
|
|
36 |
} |
|
|
37 |
$config = $container->getParameterBag()->resolveValue($config); |
|
|
38 |
|
|
|
39 |
$tmpContainer = new ContainerBuilder($container->getParameterBag()); |
|
|
40 |
$tmpContainer->addObjectResource($extension); |
|
|
41 |
|
|
|
42 |
$extension->load($config, $tmpContainer); |
|
|
43 |
|
|
|
44 |
$container->merge($tmpContainer); |
|
|
45 |
} |
|
|
46 |
|
|
|
47 |
$container->addDefinitions($definitions); |
|
|
48 |
$container->addAliases($aliases); |
|
|
49 |
$container->getParameterBag()->add($parameters); |
|
|
50 |
} |
|
|
51 |
} |