2

我有 2 个文件。

服务.yaml

imports:
    - { resource: services/service_test.yaml }

services:
    _defaults:
        autowire: true
        autoconfigure: true

和 service_test.yaml

services:
    _defaults:
      autowire: true
      autoconfigure: true

    App\Test\TestAbstract:
      abstract: true

    App\Test\TestA:
      parent: App\Test\TestAbstract
      autowire: false
      autoconfigure: false
      tags:
        - { name: app.test }

    App\Test\TestManager:
      arguments: [!tagged { tag: 'app.test' }]

我的类 TestManager 有一个构造函数

public function __construct(iterable $tests, LoggerInterface $logger)
{
    dump($tests);
    $this->logger = $logger;
}

使用该配置我有错误:

Cannot autowire service "App\Test\TestManager": argument "$tests" of method "__construct()" is type-hinted "iterable", you should configure its value explicitly.

如何使用 !tag 获取我的标记服务?

4

0 回答 0