Symfony2 - tag search in a team

I would like to know if there is a way to find the marked services in Command.

I have a team that extends ContainerAwareCommand , I can get into the container, but I would like to get all the services marked with a specific tag. For example, I would like to have something like this:

 $this->getContainer()->findTaggedServiceIds('smtp.transport') 
+6
source share
1 answer

Tagged services are available only at build time of the dependency injection container, and not at run time. Thus, in order to get all the services with a specific tag, you will need to create a compiler pass that will save a list of these services, which you can then use in your team. All of this is described in this document:

http://symfony.com/doc/current/components/dependency_injection/tags.html

+10
source

Source: https://habr.com/ru/post/924251/


All Articles