8000 Fix conflict between Bundle and ExtensionInterface · symfony/symfony@a1d3431 · GitHub
[go: up one dir, main page]

Skip to content

Commit a1d3431

Browse files
committed
Fix conflict between Bundle and ExtensionInterface
1 parent 077d206 commit a1d3431

File tree

1 file changed

+35
-46
lines changed

1 file changed

+35
-46
lines changed

src/Symfony/Component/HttpKernel/Bundle/MicroBundle.php r 8000 enamed to src/Symfony/Component/HttpKernel/Bundle/SimpleBundle.php

Lines changed: 35 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -14,92 +14,81 @@
1414
use Symfony\Component\Config\Definition\Builder\NodeParentInterface;
1515
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
1616
use Symfony\Component\Config\Definition\ConfigurationInterface;
17-
use Symfony\Component\Config\Definition\Processor;
18-
use Symfony\Component\DependencyInjection\Container;
1917
use Symfony\Component\DependencyInjection\ContainerBuilder;
20-
use Symfony\Component\DependencyInjection\Extension\ConfigurationExtensionInterface;
21-
use Symfony\Component\DependencyInjection\Extension\ExtensionInterface;
18+
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
2219

2320
/**
2421
* A all-in-one implementation of {@link BundleInterface},
2522
* {@link ExtensionInterface} and {@link ConfigurationInterface}.
2623
*
2724
* @author Guilhem N. <egetick@gmail.com>
2825
*/
29-
abstract class MicroBundle extends Bundle implements ExtensionInterface, ConfigurationExtensionInterface, ConfigurationInterface
26+
abstract class SimpleBundle extends Bundle implements ConfigurationInterface
3027
{
3128
/**
3229
* {@inheritdoc}
3330
*/
3431
final public function getContainerExtension()
3532
{
36-
return $this;
33+
return new SimpleExtension($this, function (array $config, ContainerBuilder $container) {
34+
$this->buildContainer($config, $container);
35+
});
3736
}
3837

3938
/**
4039
* {@inheritdoc}
4140
*/
42-
public function getXsdValidationBasePath()
41+
final public function getConfigTreeBuilder()
4342
{
44-
return false;
43+
$treeBuilder = new TreeBuilder();
44+
$rootNode = $treeBuilder->root($this->getAlias());
45+
46+
$this->buildConfiguration($rootNode);
47+
48+
return $treeBuilder;
4549
}
4650

47-
/**
48-
* {@inheritdoc}
49-
*/
50-
public function getNamespace()
51+
protected function buildConfiguration(NodeParentInterface $rootNode)
5152
{
52-
return 'http://example.org/schema/dic/'.$this->getAlias();
5353
}
5454

55-
/**
56-
* {@inheritdoc}
57-
*/
58-
public function getAlias()
55+
protected function buildContainer(array $config, ContainerBuilder $container)
5956
{
60-
// check naming convention
61-
$basename = preg_replace('/Bundle$/', '', $this->getName());
62-
63-
return Container::underscore($basename);
6457
}
58+
}
6559

66-
/**
67-
* {@inheritdoc}
68-
*/
69-
final public function load(array $configs, ContainerBuilder $container)
70-
{
71-
$processor = new Processor();
72-
$config = $processor->processConfiguration($this, $configs);
60+
/**
61+
* Simple {@link ExtensionInterface} supporting {@link MicroBundle}.
62+
*
63+
* @internal
64+
*/
65+
final class SimpleExtension extends Extension
66+
{
67+
private $bundle;
68+
private $buildContainer;
7369

74-
$this->buildContainer($config, $container);
70+
public function __construct(SimpleBundle $bundle, Closure $buildContainer)
71+
{
72+
$this->bundle = $bundle;
73+
$this->buildContainer = $buildContainer;
7574
}
7675

7776
/**
7877
* {@inheritdoc}
7978
*/
80-
final public function getConfiguration(array $config, ContainerBuilder $container)
79+
public function load(array $configs, ContainerBuilder $container)
8180
{
82-
return $this;
81+
$config = $this->processConfiguration($this->bundle, $configs);
82+
83+
$f = $this->buildContainer;
84+
$f($config, $container);
8385
}
8486

8587
/**
8688
* {@inheritdoc}
8789
*/
88-
final public function getConfigTreeBuilder()
89-
{
90-
$treeBuilder = new TreeBuilder();
91-
$rootNode = $treeBuilder->root($this->getAlias());
92-
93-
$this->buildConfiguration($rootNode);
94-
95-
return $treeBuilder;
96-
}
97-
98-
protected function buildConfiguration(NodeParentInterface $rootNode)
99-
{
100-
}
101-
102-
protected function buildContainer(array $config, ContainerBuilder $container)
90+
public function getConfiguration(array $config, ContainerBuilder $container)
10391
{
92+
return $this->bundle;
10493
}
10594
}

0 commit comments

Comments
 (0)
0