Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Symfony2 - Find tagged services in command

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

I have a Command that extends ContainerAwareCommand, I'm able to get to container but I would like to get all services that is tagged by a specific tag. For example, I'd like to have something like that:

$this->getContainer()->findTaggedServiceIds('smtp.transport')
like image 899
passkey1510 Avatar asked Aug 31 '12 08:08

passkey1510


1 Answers

Tagged services are only available at build-time of the dependency injection container, not at run-time. So, to get all services with a certain tag you will need to build a compiler pass that saves a list of these services which you can then latter use in your command. This is all described in this document:

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

like image 184
Carlos Granados Avatar answered Sep 19 '22 12:09

Carlos Granados