From e41ad56816d8a613e25e1fe4fe85a1d90a49c7ec Mon Sep 17 00:00:00 2001 From: Alexandre Daubois Date: Mon, 6 Jan 2025 09:04:55 +0100 Subject: [PATCH] [DependencyInjection] Make `#[AsTaggedItem]` repeatable --- service_container/tags.rst | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/service_container/tags.rst b/service_container/tags.rst index 270d6702f5a..d725efc3a17 100644 --- a/service_container/tags.rst +++ b/service_container/tags.rst @@ -1281,4 +1281,24 @@ be used directly on the class of the service you want to configure:: // ... } +The attribute can be repeated on the same class to define multiple tags +with different indexes and priorities:: + + // src/Handler/One.php + namespace App\Handler; + + use Symfony\Component\DependencyInjection\Attribute\AsTaggedItem; + + #[AsTaggedItem(index: 'handler_one', priority: 10)] + #[AsTaggedItem(index: 'handler_two', priority: 20)] + class One + { + // ... + } + +.. versionadded:: 7.3 + + The support for repeated ``#[AsTaggedItem]`` attributes was introduced in + Symfony 7.3. + .. _`PHP constructor promotion`: https://www.php.net/manual/en/language.oop5.decon.php#language.oop5.decon.constructor.promotion