Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit cd9e68a

Browse files
committed
feature #17695 [DependencyInjection] Add #[Autoconfigure] and #[AutoconfigureTag] documentation (alexandre-daubois)
This PR was merged into the 5.4 branch. Discussion ---------- [DependencyInjection] Add `#[Autoconfigure]` and `#[AutoconfigureTag]` documentation Closes #14990 Part of #17563 Commits ------- ce16301 [DependencyInjection] Add #[Autoconfigure] and #[AutoconfigureTag] documentation
2 parents 0476f31 + ce16301 commit cd9e68a

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

service_container/tags.rst

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,29 @@ If you want to apply tags automatically for your own services, use the
117117
->tag('app.custom_tag');
118118
};
119119
120+
It is also possible to use the ``#[AutoconfigureTag]`` attribute directly on the
121+
base class or interface::
122+
123+
// src/Security/CustomInterface.php
124+
namespace App\Security;
125+
126+
use Symfony\Component\DependencyInjection\Attribute\AutoconfigureTag;
127+
128+
#[AutoconfigureTag('app.custom_tag')]
129+
interface CustomInterface
130+
{
131+
// ...
132+
}
133+
134+
.. tip::
135+
136+
If you need more capabilities to autoconfigure instances of your base class
137+
like their laziness, their bindings or their calls for example, you may rely
138+
on the :class:`Symfony\\Component\\DependencyInjection\\Attribute\\Autoconfigure` attribute.
139+
140+
.. versionadded:: 5.3
141+
142+
The ``#[Autoconfigure]`` and ``#[AutoconfigureTag]`` attributes were introduced in Symfony 5.3.
120143

121144
For more advanced needs, you can define the automatic tags using the
122145
:method:`Symfony\\Component\\DependencyInjection\\ContainerBuilder::registerForAutoconfiguration` method.

0 commit comments

Comments
 (0)