Skip to content

Commit 9e42c2b

Browse files
committed
feature #17694 [DependencyInjection] Add #[AsTaggedItem] documentation (alexandre-daubois)
This PR was merged into the 5.4 branch. Discussion ---------- [DependencyInjection] Add `#[AsTaggedItem]` documentation Part of #17563 Commits ------- 49e2405 [DependencyInjection] Add #[AsTaggedItem] documentation
2 parents 29ad979 + 49e2405 commit 9e42c2b

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

service_container/tags.rst

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -897,3 +897,25 @@ array element. For example, to retrieve the ``handler_two`` handler::
897897
])
898898
;
899899
};
900+
901+
The #[AsTaggedItem] attribute
902+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
903+
904+
It is possible to define both the priority and the index of a tagged
905+
item thanks to the ``#[AsTaggedItem]`` attribute. This attribute must
906+
be used directly on the class of the service you want to configure::
907+
908+
// src/Handler/One.php
909+
namespace App\Handler;
910+
911+
use Symfony\Component\DependencyInjection\Attribute\AsTaggedItem;
912+
913+
#[AsTaggedItem(index: 'handler_one', priority: 10)]
914+
class One
915+
{
916+
// ...
917+
}
918+
919+
.. versionadded:: 5.3
920+
921+
The ``#[AsTaggedItem]`` attribute was introduced in Symfony 5.3 and requires PHP 8.

0 commit comments

Comments
 (0)