| 148 |
lars |
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\HttpKernel\Bundle;
|
|
|
13 |
|
|
|
14 |
use Symfony\Component\Config\Definition\Configuration;
|
|
|
15 |
use Symfony\Component\Config\Definition\ConfigurationInterface;
|
|
|
16 |
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
|
|
17 |
use Symfony\Component\DependencyInjection\Extension\ConfigurableExtensionInterface;
|
|
|
18 |
use Symfony\Component\DependencyInjection\Extension\Extension;
|
|
|
19 |
use Symfony\Component\DependencyInjection\Extension\ExtensionTrait;
|
|
|
20 |
use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface;
|
|
|
21 |
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
|
|
22 |
|
|
|
23 |
/**
|
|
|
24 |
* @author Yonel Ceruto <yonelceruto@gmail.com>
|
|
|
25 |
*
|
|
|
26 |
* @internal
|
|
|
27 |
*/
|
|
|
28 |
class BundleExtension extends Extension implements PrependExtensionInterface
|
|
|
29 |
{
|
|
|
30 |
use ExtensionTrait;
|
|
|
31 |
|
|
|
32 |
public function __construct(
|
|
|
33 |
private ConfigurableExtensionInterface $subject,
|
|
|
34 |
private string $alias,
|
|
|
35 |
) {
|
|
|
36 |
}
|
|
|
37 |
|
|
|
38 |
public function getConfiguration(array $config, ContainerBuilder $container): ?ConfigurationInterface
|
|
|
39 |
{
|
|
|
40 |
return new Configuration($this->subject, $container, $this->getAlias());
|
|
|
41 |
}
|
|
|
42 |
|
|
|
43 |
public function getAlias(): string
|
|
|
44 |
{
|
|
|
45 |
return $this->alias;
|
|
|
46 |
}
|
|
|
47 |
|
|
|
48 |
public function prepend(ContainerBuilder $container): void
|
|
|
49 |
{
|
|
|
50 |
$callback = function (ContainerConfigurator $configurator) use ($container) {
|
|
|
51 |
$this->subject->prependExtension($configurator, $container);
|
|
|
52 |
};
|
|
|
53 |
|
|
|
54 |
$this->executeConfiguratorCallback($container, $callback, $this->subject);
|
|
|
55 |
}
|
|
|
56 |
|
|
|
57 |
public function load(array $configs, ContainerBuilder $container): void
|
|
|
58 |
{
|
|
|
59 |
$config = $this->processConfiguration($this->getConfiguration([], $container), $configs);
|
|
|
60 |
|
|
|
61 |
$callback = function (ContainerConfigurator $configurator) use ($config, $container) {
|
|
|
62 |
$this->subject->loadExtension($config, $configurator, $container);
|
|
|
63 |
};
|
|
|
64 |
|
|
|
65 |
$this->executeConfiguratorCallback($container, $callback, $this->subject);
|
|
|
66 |
}
|
|
|
67 |
}
|