Skip to content

Commit e41ad56

Browse files
[DependencyInjection] Make #[AsTaggedItem] repeatable
1 parent b7f126c commit e41ad56

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

service_container/tags.rst

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1281,4 +1281,24 @@ be used directly on the class of the service you want to configure::
12811281
// ...
12821282
}
12831283

1284+
The attribute can be repeated on the same class to define multiple tags
1285+
with different indexes and priorities::
1286+
1287+
// src/Handler/One.php
1288+
namespace App\Handler;
1289+
1290+
use Symfony\Component\DependencyInjection\Attribute\AsTaggedItem;
1291+
1292+
#[AsTaggedItem(index: 'handler_one', priority: 10)]
1293+
#[AsTaggedItem(index: 'handler_two', priority: 20)]
1294+
class One
1295+
{
1296+
// ...
1297+
}
1298+
1299+
.. versionadded:: 7.3
1300+
1301+
The support for repeated ``#[AsTaggedItem]`` attributes was introduced in
1302+
Symfony 7.3.
1303+
12841304
.. _`PHP constructor promotion`: https://www.php.net/manual/en/language.oop5.decon.php#language.oop5.decon.constructor.promotion

0 commit comments

Comments
 (0)