# config/services.yaml
services:
_instanceof:
App\Foo\FooInterface:
tags: ['app.foo_tag']
namespace App;
class HandlerCollection
{
public function __construct(
// the attribute must be applied directly to the argument to autowire
#[TaggedIterator('app.foo_tag')]
iterable $handlers
) {
}
}
App\HandlerCollection:
# inject all services tagged with app. foo_tag as first argument
arguments:
- !tagged_iterator app.foo_tag
.md — это маркдаун, можете к нему инструкцию глянуть