@@ -155,22 +155,30 @@ In a Symfony application, call this method in your kernel class::
155
155
}
156
156
}
157
157
158
- In a Symfony bundle, call this method in the `` load() `` method of the
159
- :doc: ` bundle extension class < /bundles/extension >` ::
158
+ In bundles extending the :class: ` Symfony \\ Component \\ HttpKernel \\ Bundle \\ AbstractBundle `
159
+ class, call this method in the `` loadExtension() `` method of the main bundle class ::
160
160
161
- // src/DependencyInjection/MyBundleExtension.php
162
- class MyBundleExtension extends Extension
161
+ // ...
162
+ use Symfony\Component\DependencyInjection\ContainerBuilder;
163
+ use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
164
+ use Symfony\Component\HttpKernel\Bundle\AbstractBundle;
165
+
166
+ class MyBundle extends AbstractBundle
163
167
{
164
- // ...
165
-
166
- public function load(array $configs, ContainerBuilder $container): void
168
+ public function loadExtension(array $config, ContainerConfigurator $container, ContainerBuilder $builder): void
167
169
{
168
- $container->registerForAutoconfiguration(CustomInterface::class)
170
+ $builder
171
+ ->registerForAutoconfiguration(CustomInterface::class)
169
172
->addTag('app.custom_tag')
170
173
;
171
174
}
172
175
}
173
176
177
+ .. note ::
178
+
179
+ For bundles not extending the ``AbstractBundle `` class, call this method in
180
+ the ``load() `` method of the :doc: `bundle extension class </bundles/extension >`.
181
+
174
182
Autoconfiguration registering is not limited to interfaces. It is possible
175
183
to use PHP attributes to autoconfigure services by using the
176
184
:method: `Symfony\\ Component\\ DependencyInjection\\ ContainerBuilder::registerAttributeForAutoconfiguration `
0 commit comments