File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -591,6 +591,26 @@ application handlers::
591591 }
592592 }
593593
594+ Injecting tagged services can be also be done through autowiring thanks to the
595+ ``#[TaggedIterator] `` attribute. This attribute must be directly used on the
596+ argument to autowire::
597+
598+ // src/HandlerCollection.php
599+ namespace App;
600+
601+ use Symfony\Component\DependencyInjection\Attribute\TaggedIterator;
602+
603+ class HandlerCollection
604+ {
605+ public function __construct(#[TaggedIterator('app.handler')] iterable $handlers)
606+ {
607+ }
608+ }
609+
610+ .. versionadded :: 5.3
611+
612+ The ``#[TaggedIterator] `` attribute was introduced in Symfony 5.3 and requires PHP 8.
613+
594614.. seealso ::
595615
596616 See also :doc: `tagged locator services </service_container/service_subscribers_locators >`
You can’t perform that action at this time.
0 commit comments