@@ -306,6 +306,7 @@ For more details, see :doc:`/cookbook/bundles/prepend_extension`, which
306
306
is specific to the Symfony Framework, but contains more details about this
307
307
feature.
308
308
309
+ .. _creating-a-compiler-pass :
309
310
.. _components-di-compiler-pass :
310
311
311
312
Execute Code During Compilation
@@ -332,8 +333,8 @@ compilation::
332
333
333
334
.. versionadded :: 2.8
334
335
Prior to Symfony 2.8, extensions implementing ``CompilerPassInterface ``
335
- were not automatically registered. You need to register it as explained in
336
- :ref: `the next section <components-di-separate-compiler-passes >`.
336
+ were not automatically registered. You needed to register them as explained
337
+ in :ref: `the next section <components-di-separate-compiler-passes >`.
337
338
338
339
As ``process() `` is called *after * all extensions are loaded, it allows you to
339
340
edit service definitions of other extensions as well as retrieving information
@@ -342,10 +343,17 @@ about service definitions.
342
343
The container's parameters and definitions can be manipulated using the
343
344
methods described in :doc: `/components/dependency_injection/definitions `.
344
345
346
+ .. note ::
347
+
348
+ Please note that the ``process() `` method in the extension classes is
349
+ called during the optimization step. You can read
350
+ :ref: `the next section <components-di-separate-compiler-passes >` if you
351
+ need to edit the container during another step.
352
+
345
353
.. note ::
346
354
347
355
As a rule, only work with services definition in a compiler pass and do not
348
- create service instances. Practically , this means using methods ``has() ``,
356
+ create service instances. In practice , this means using methods ``has() ``,
349
357
``findDefinition() ``, ``getDefinition() ``, ``setDefinition() ``, etc.
350
358
instead of ``get() ``, ``set() ``, etc.
351
359
@@ -364,9 +372,10 @@ for an example.
364
372
Creating Separate Compiler Passes
365
373
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
366
374
367
- Sometimes, you need to do more than one thing during compliation or want to use
368
- compiler passes without an extension. In this case, you can create a new class
369
- implementing the ``CompilerPassInterface ``::
375
+ Sometimes, you need to do more than one thing during compliation, want to use
376
+ compiler passes without an extension or you need to execute some code at
377
+ another step in the compilation process. In these cases, you can create a new
378
+ class implementing the ``CompilerPassInterface ``::
370
379
371
380
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
372
381
use Symfony\Component\DependencyInjection\ContainerBuilder;
0 commit comments