File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -70,6 +70,20 @@ 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
78+
79+ // ...
80+ public function load(array $configs, ContainerBuilder $container)
81+ {
82+ $container->registerForAutoconfiguration(CustomInterface::class)
83+ ->addTag('app.custom_tag')
84+ ;
85+ }
86+
7387Creating custom Tags
7488--------------------
7589
You can’t perform that action at this time.
0 commit comments