Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Closed
wouterj wants to merge2 commits intosymfony:2.8fromwouterj:extension_compiler_pass
Closed
Show file tree
Hide file tree
Changes from1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
PrevPrevious commit
Applied comments
  • Loading branch information
@wouterj
wouterj committedJan 21, 2016
commitd429442c768da83575927d12ec77dd9a99fe6efc
25 changes: 17 additions & 8 deletionscomponents/dependency_injection/compilation.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -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:
Copy link
Member

Choose a reason for hiding this comment

The 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
Expand All@@ -332,8 +333,8 @@ compilation::

.. versionadded:: 2.8
Prior to Symfony 2.8, extensions implementing ``CompilerPassInterface``
were not automatically registered. Youneed to registerit as explained in
:ref:`the next section <components-di-separate-compiler-passes>`.
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
Expand All@@ -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.Practically, this means usingmethods ``has()``,
``findDefinition()``, ``getDefinition()``, ``setDefinition()``, etc.
instead of ``get()``, ``set()``, etc.
create service instances.In practice, this means usingthe methods
``has()``, ``findDefinition()``, ``getDefinition()``, ``setDefinition()``,
etc.instead of ``get()``, ``set()``, etc.

.. tip::

Expand All@@ -364,9 +372,10 @@ for an example.
Creating Separate Compiler Passes
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Sometimes, you need to do more than one thing during compliation or want to use
compiler passes without an extension. In this case, you can create a new class
implementing the ``CompilerPassInterface``::
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;
Expand Down
5 changes: 3 additions & 2 deletionscomponents/dependency_injection/tags.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -118,9 +118,10 @@ the custom tag that you'll use in your compiler pass. The compiler pass
is what makes this tag "mean" something.

.. _components-di-compiler-pass-tags:
.. _create-a-compilerpass:

Create aCompilerPass
---------------------
Create aCompiler Pass
----------------------

You can now use a :ref:`compiler pass <components-di-separate-compiler-passes>` to ask the
container for any services with the ``acme_mailer.transport`` tag::
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp