Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit375c481

Browse files
committed
minor#17652 [DependencyInjection] Autowire arguments using the #[TaggedIterator] attribute (alexandre-daubois)
This PR was merged into the 5.4 branch.Discussion----------[DependencyInjection] Autowire arguments using the #[TaggedIterator] attributePartially solves#15238.As tagged locator are not mentioned here, I guess it should be done somewhere else.Commits-------0db7228 [DependencyInjection] Autowire arguments using the #[TaggedIterator] attribute
2 parentsdb74d6d +0db7228 commit375c481

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
@@ -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>`

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp