Skip to content

Commit 79227c8

Browse files
committed
[#2007] Proofreading the new prepend extension docs, adding some other links/notes to other sections
1 parent 907fe4d commit 79227c8

File tree

4 files changed

+34
-17
lines changed

4 files changed

+34
-17
lines changed

components/dependency_injection/compilation.rst

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,9 +248,12 @@ but also load a secondary one only if a certain parameter is set::
248248

249249
.. _components-dependency-injection-compiler-passes:
250250

251-
Prepending configuration passed to the Extension
251+
Prepending Configuration passed to the Extension
252252
------------------------------------------------
253253

254+
.. versionadded:: 2.1
255+
The ability to prepend the configuration of a bundle is new in Symfony 2.2.
256+
254257
An Extension can prepend the configuration of any Bundle before the ``load()``
255258
method is called by implementing :class:`Symfony\\Component\\DependencyInjection\\Compiler\\PrependExtensionInterface`::
256259

@@ -271,6 +274,9 @@ method is called by implementing :class:`Symfony\\Component\\DependencyInjection
271274
}
272275
}
273276

277+
For more details, see :doc:`/cookbook/bundles/prepend_extension`, which is
278+
specific to the Symfony2 Framework, but contains more details about this feature.
279+
274280
Creating a Compiler Pass
275281
------------------------
276282

cookbook/bundles/extension.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -483,6 +483,16 @@ normalization and advanced merging. You can read more about this in :doc:`the Co
483483
You can also see it action by checking out some of the core Configuration classes,
484484
such as the one from the `FrameworkBundle Configuration`_ or the `TwigBundle Configuration`_.
485485

486+
Modifying the configuration of another Bundle
487+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
488+
489+
If you have multiple bundles that depend on each other, it may be useful
490+
to allow one ``Extension`` class to modify the configuration passed to another
491+
bundle's ``Extension`` class, as if the end-developer has actually placed that
492+
configuration in his/her ``app/config/config.yml`` file.
493+
494+
For more details, see :doc:`/cookbook/bundles/prepend_extension`.
495+
486496
Default Configuration Dump
487497
~~~~~~~~~~~~~~~~~~~~~~~~~~
488498

cookbook/bundles/prepend_extension.rst

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,24 @@
55
How to simplify configuration of multiple Bundle
66
================================================
77

8-
Especially when building reusable and extensible applications developers are
9-
often faced with a choice, either create a single Bundle or create multiple
10-
Bundles. Creating a single Bundle has the draw back that its impossible for
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
1111
users to choose to remove functionality they are not using. Creating multiple
1212
Bundles has the draw back that configuration becomes more tedious and settings
1313
often need to be repeated for various Bundles.
1414

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
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
1717
for any Bundle. It can use the settings defined in the ``app/config/config.yml``
1818
to prepend settings just as if they would have been written explicitly by the
1919
user in the application configuration.
2020

2121
For example, this could be used to configure the entity manager name to use in
22-
multiple Bundle. Or it can be used to enable an optional feature that depends
22+
multiple Bundles. Or it can be used to enable an optional feature that depends
2323
on another Bundle being loaded as well.
2424

25-
In order for an Extension to be able to do this it needs to implement
25+
To give an Extension the power to do this, it needs to implement
2626
:class:`Symfony\\Component\\DependencyInjection\\Compiler\\PrependExtensionInterface`::
2727

2828
// src/Acme/HelloBundle/DependencyInjection/AcmeHelloExtension.php
@@ -42,19 +42,19 @@ In order for an Extension to be able to do this it needs to implement
4242
}
4343
}
4444

45-
Inside the :method:`Symfony\\Component\\DependencyInjection\\Compiler\\PrependExtensionInterface::prepend()`
46-
method developers have full access to the :class:`Symfony\Component\DependencyInjection\ContainerBuilder`
47-
instance just before the :method:`Symfony\Component\HttpKernel\DependencyInjection\ExtensionInterface:load()`
48-
method is called on the registered Bundle Extensions. In order to prepend settings
49-
to a Bundle extension developers can use the
50-
:method:`Symfony\Component\DependencyInjection\ContainerBuilder:prependExtensionConfig()`
51-
method on the :class:`Symfony\Component\DependencyInjection\ContainerBuilder`
45+
Inside the :method:`Symfony\\Component\\DependencyInjection\\Compiler\\PrependExtensionInterface::prepend`
46+
method, developers have full access to the :class:`Symfony\\Component\\DependencyInjection\\ContainerBuilder`
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
50+
:method:`Symfony\\Component\\DependencyInjection\\ContainerBuilder::prependExtensionConfig`
51+
method on the :class:`Symfony\\Component\\DependencyInjection\\ContainerBuilder`
5252
instance. As this method only prepends settings, any other settings done explicitly
5353
inside the ``app/config/config.yml`` would override these prepended settings.
5454

5555
The following example illustrates how to prepend
5656
a configuration setting in multiple Bundles as well as disable a flag in multiple Bundles
57-
in case specific other Bundle is not registered::
57+
in case a specific other Bundle is not registered::
5858

5959
public function prepend(ContainerBuilder $container)
6060
{
@@ -92,7 +92,7 @@ in case specific other Bundle is not registered::
9292

9393
The above would be the equivalent of writing the following into the ``app/config/config.yml``
9494
in case ``AcmeGoodbyeBundle`` is not registered and the ``entity_manager_name`` setting
95-
for ``acme_hello`` is set to ``non_default``::
95+
for ``acme_hello`` is set to ``non_default``:
9696

9797
.. configuration-block::
9898

cookbook/map.rst.inc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
* :doc:`/cookbook/bundles/inheritance`
1212
* :doc:`/cookbook/bundles/override`
1313
* :doc:`/cookbook/bundles/extension`
14+
* :doc:`/cookbook/bundles/prepend_extension`
1415

1516
* :doc:`/cookbook/cache/index`
1617

0 commit comments

Comments
 (0)