@@ -67,37 +67,9 @@ method of the application kernel::
6767Working with Compiler Passes in Bundles
6868---------------------------------------
6969
70- If your compiler pass is relatively small, you can add it directly in the main
71- bundle class. To do so, make your bundle implement the
72- :class: `Symfony\\ Component\\ DependencyInjection\\ Compiler\\ CompilerPassInterface `
73- and place the compiler pass code inside the ``process() `` method of the main
74- bundle class::
75-
76- // src/MyBundle/MyBundle.php
77- namespace App\MyBundle;
78-
79- use App\DependencyInjection\Compiler\CustomPass;
80- use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
81- use Symfony\Component\DependencyInjection\ContainerBuilder;
82- use Symfony\Component\HttpKernel\Bundle\AbstractBundle;
83-
84- class MyBundle extends AbstractBundle implements CompilerPassInterface
85- {
86- public function process(ContainerBuilder $container): void
87- {
88- // in this method you can manipulate the service container:
89- // for example, changing some container service:
90- $container->getDefinition('app.some_private_service')->setPublic(true);
91-
92- // or processing tagged services:
93- foreach ($container->findTaggedServiceIds('some_tag') as $id => $tags) {
94- // ...
95- }
96- }
97- }
98-
99- Alternatively, when using :ref: `separate compiler pass classes <components-di-separate-compiler-passes >`,
100- bundles can enable them in the ``build() `` method of their main bundle class::
70+ :doc: `Bundles </bundles >` can define compiler passes in the ``build() `` method of
71+ the main bundle class (this is not needed when implementing the ``process() ``
72+ method in the extension)::
10173
10274 // src/MyBundle/MyBundle.php
10375 namespace App\MyBundle;
0 commit comments