@@ -6,21 +6,21 @@ How to simplify configuration of multiple Bundles
6
6
=================================================
7
7
8
8
When building reusable and extensible applications, developers are often
9
- faced with a choice: either create a single large Bundle or multiple smaller
10
- Bundles . Creating a single Bundle has the draw back that it's impossible for
9
+ faced with a choice: either create a single large bundle or multiple smaller
10
+ bundles . Creating a single bundle has the drawback that it's impossible for
11
11
users to choose to remove functionality they are not using. Creating multiple
12
- Bundles has the draw back that configuration becomes more tedious and settings
13
- often need to be repeated for various Bundles .
12
+ bundles has the drawback that configuration becomes more tedious and settings
13
+ often need to be repeated for various bundles .
14
14
15
15
Using the below approach, it is possible to remove the disadvantage of the
16
- multiple Bundle approach by enabling a single Extension to prepend the settings
17
- for any Bundle . It can use the settings defined in the ``app/config/config.yml ``
18
- to prepend settings just as if they would have been written explicitly by the
19
- user in the application configuration.
16
+ multiple bundle approach by enabling a single Extension to prepend the settings
17
+ for any bundle . It can use the settings defined in the ``app/config/config.yml ``
18
+ to prepend settings just as if they would have been written explicitly by
19
+ the user in the application configuration.
20
20
21
21
For example, this could be used to configure the entity manager name to use in
22
- multiple Bundles . Or it can be used to enable an optional feature that depends
23
- on another Bundle being loaded as well.
22
+ multiple bundles . Or it can be used to enable an optional feature that depends
23
+ on another bundle being loaded as well.
24
24
25
25
To give an Extension the power to do this, it needs to implement
26
26
:class: `Symfony\\ Component\\ DependencyInjection\\ Extension\\ PrependExtensionInterface `::
@@ -45,24 +45,24 @@ To give an Extension the power to do this, it needs to implement
45
45
Inside the :method: `Symfony\\ Component\\ DependencyInjection\\ Extension\\ PrependExtensionInterface::prepend `
46
46
method, developers have full access to the :class: `Symfony\\ Component\\ DependencyInjection\\ ContainerBuilder `
47
47
instance just before the :method: `Symfony\\ Component\\ DependencyInjection\\ Extension\\ ExtensionInterface::load `
48
- method is called on each of the registered Bundle Extensions. In order to
49
- prepend settings to a Bundle extension developers can use the
48
+ method is called on each of the registered bundle Extensions. In order to
49
+ prepend settings to a bundle extension developers can use the
50
50
:method: `Symfony\\ Component\\ DependencyInjection\\ ContainerBuilder::prependExtensionConfig `
51
51
method on the :class: `Symfony\\ Component\\ DependencyInjection\\ ContainerBuilder `
52
52
instance. As this method only prepends settings, any other settings done explicitly
53
53
inside the ``app/config/config.yml `` would override these prepended settings.
54
54
55
55
The following example illustrates how to prepend
56
- a configuration setting in multiple Bundles as well as disable a flag in multiple Bundles
57
- in case a specific other Bundle is not registered::
56
+ a configuration setting in multiple bundles as well as disable a flag in multiple bundles
57
+ in case a specific other bundle is not registered::
58
58
59
59
public function prepend(ContainerBuilder $container)
60
60
{
61
- // get all Bundles
61
+ // get all bundles
62
62
$bundles = $container->getParameter('kernel.bundles');
63
63
// determine if AcmeGoodbyeBundle is registered
64
64
if (!isset($bundles['AcmeGoodbyeBundle'])) {
65
- // disable AcmeGoodbyeBundle in Bundles
65
+ // disable AcmeGoodbyeBundle in bundles
66
66
$config = array('use_acme_goodbye' => false);
67
67
foreach ($container->getExtensions() as $name => $extension) {
68
68
switch ($name) {
0 commit comments