File tree Expand file tree Collapse file tree 1 file changed +17
-12
lines changed Expand file tree Collapse file tree 1 file changed +17
-12
lines changed Original file line number Diff line number Diff line change @@ -70,19 +70,24 @@ then some tags are automatically applied for you. That's true for the ``twig.ext
7070tag: the container sees that your class extends ``Twig_Extension `` (or more accurately,
7171that it implements ``Twig_ExtensionInterface ``) and adds the tag for you.
7272
73- In order to have a tag automatically applied to all your services that implement an interface,
74- you should create an extension following the steps described in :doc: `/bundles/extension `,
75- then in the ``load() `` method call ``registerForAutoconfiguration() `` and apply your tag::
76-
77- // src/AppBundle/DependencyInjection/AppExtension.php
73+ .. tip ::
7874
79- // ...
80- public function load(array $configs, ContainerBuilder $container)
81- {
82- $container->registerForAutoconfiguration(CustomInterface::class)
83- ->addTag('app.custom_tag')
84- ;
85- }
75+ To apply a tag to all your autoconfigured services extending a class or an
76+ interface, call ``ContainerBuilder::registerForAutoconfiguration() `` in an
77+ :doc: `extension </bundles/extension >` or from your kernel::
78+
79+ // app/AppKernel.php
80+ class AppKernel extends Kernel
81+ {
82+ // ...
83+
84+ protected function build(ContainerBuilder $container)
85+ {
86+ $container->registerForAutoconfiguration(CustomInterface::class)
87+ ->addTag('app.custom_tag')
88+ ;
89+ }
90+ }
8691
8792Creating custom Tags
8893--------------------
You can’t perform that action at this time.
0 commit comments