Skip to content

Commit a75e099

Browse files
committed
Merge branch '7.2' into 7.3
* 7.2: Tweaks Update tags.rst
2 parents d53cc63 + 7b9ffb2 commit a75e099

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

service_container/tags.rst

+16-8
Original file line numberDiff line numberDiff line change
@@ -155,22 +155,30 @@ In a Symfony application, call this method in your kernel class::
155155
}
156156
}
157157

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::
160160

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
163167
{
164-
// ...
165-
166-
public function load(array $configs, ContainerBuilder $container): void
168+
public function loadExtension(array $config, ContainerConfigurator $container, ContainerBuilder $builder): void
167169
{
168-
$container->registerForAutoconfiguration(CustomInterface::class)
170+
$builder
171+
->registerForAutoconfiguration(CustomInterface::class)
169172
->addTag('app.custom_tag')
170173
;
171174
}
172175
}
173176

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+
174182
Autoconfiguration registering is not limited to interfaces. It is possible
175183
to use PHP attributes to autoconfigure services by using the
176184
:method:`Symfony\\Component\\DependencyInjection\\ContainerBuilder::registerAttributeForAutoconfiguration`

0 commit comments

Comments
 (0)