Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork5.2k
Document automatic registration of extension compiler passes#5920
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes from1 commit
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
- Loading branch information
Uh oh!
There was an error while loading.Please reload this page.
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -306,6 +306,7 @@ For more details, see :doc:`/cookbook/bundles/prepend_extension`, which | ||
is specific to the Symfony Framework, but contains more details about this | ||
feature. | ||
.. _creating-a-compiler-pass: | ||
.. _components-di-compiler-pass: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. We should also add a label for the old headline. | ||
Execute Code During Compilation | ||
@@ -332,8 +333,8 @@ compilation:: | ||
.. versionadded:: 2.8 | ||
Prior to Symfony 2.8, extensions implementing ``CompilerPassInterface`` | ||
were not automatically registered. Youneeded to registerthem as explained | ||
in:ref:`the next section <components-di-separate-compiler-passes>`. | ||
As ``process()`` is called *after* all extensions are loaded, it allows you to | ||
edit service definitions of other extensions as well as retrieving information | ||
@@ -342,12 +343,19 @@ about service definitions. | ||
The container's parameters and definitions can be manipulated using the | ||
methods described in :doc:`/components/dependency_injection/definitions`. | ||
.. note:: | ||
Please note that the ``process()`` method in the extension class is | ||
called during the optimization step. You can read | ||
:ref:`the next section <components-di-separate-compiler-passes>` if you | ||
need to edit the container during another step. | ||
.. note:: | ||
As a rule, only work with services definition in a compiler pass and do not | ||
create service instances.In practice, this means usingthe methods | ||
``has()``, ``findDefinition()``, ``getDefinition()``, ``setDefinition()``, | ||
etc.instead of ``get()``, ``set()``, etc. | ||
.. tip:: | ||
@@ -364,9 +372,10 @@ for an example. | ||
Creating Separate Compiler Passes | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
Sometimes, you need to do more than one thing during compliation, want to use | ||
compiler passes without an extension or you need to execute some code at | ||
another step in the compilation process. In these cases, you can create a new | ||
class implementing the ``CompilerPassInterface``:: | ||
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; | ||
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||