Symfony 3.3 - 启用自动装配时容器如何知道服务的标签?

Symfony 3.3 - How can the container know the tag of the service when autowiring is enabled?

我有一个服务有两个标签,extended_typename

启用自动装配后,如何定义这些标签?

Edit: This is my class form extension

use Symfony\Component\Form\AbstractTypeExtension;
use Symfony\Component\Form\Extension\Core\Type\DateTimeType;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\Form\FormView;
class DateTimeTypeExtension extends AbstractTypeExtension
{
    public function getExtendedType()
    {
        return DateTimeType::class;
    }

    public function buildView( FormView $view, FormInterface $form, array $options )
    {
        $view->vars['date_time_help'] = 'Format d-m-Y.';
    }

}

表单类型扩展服务需要定义两个标签extended_typename

从 Symfony 3.3 开始,如果您启用自动配置,则会自动为您应用一些标签,例如 twig.extension。 启用自动配置不适用于所有标签。许多标签都有必需的属性,例如事件侦听器,您还需要在标签中指定事件名称和方法。自动配置仅适用于没有任何必需标签属性的标签

在您的情况下,您需要在 app/config/service.yml 中覆盖您的服务并明确定义您的标签,如下所示:

AppBundle\Service\YourService:
        tags:
            - { name: service1, extended_type: service2 }