Yes, i thought i can use it instead if event-engine, but i see it's not 
good way.

But you can get tagged services by tag in Controller:
 

class SomeController extends Controller {
>
>     protected $containerBuilder;
>
>     /**
>      * @Route("/someurl/{name}")
>      * Template()
>      */
>     public function indexAction($name) {
>         $tag = 'some.tag';
>
>         $controller_list = $this->container->getServiceIds();
>         $this->containerBuilder = $this->getContainerBuilder();
>
>         $tags = array();
>
>         foreach ($controller_list as $id) {
>
>             $definition = $this->resolveServiceDefinition($id);
>
>             if ($definition instanceof Definition && in_array($tag, 
> array_keys($definition->getTags()))) {
>                 $tags[] = $id;
>             }
>         } 
>
        return array();
>     }
>
>     protected function resolveServiceDefinition($serviceId) {
>         if ($this->containerBuilder->hasDefinition($serviceId)) {
>             return $this->containerBuilder->getDefinition($serviceId);
>         }
>
>         // Some service IDs don't have a Definition, they're simply an 
> Alias
>         if ($this->containerBuilder->hasAlias($serviceId)) {
>             return $this->containerBuilder->getAlias($serviceId);
>         }
>
>         // the service has been injected in some special way, just return 
> the service
>         return $this->containerBuilder->get($serviceId);
>     }
>
>     protected function getContainerBuilder() {
>         if (!is_file($cachedFile = 
> $this->container->getParameter('debug.container.dump'))) {
>             throw new \LogicException(sprintf('Debug information about the 
> container could not be found. Please clear the cache and try again.'));
>         }
>
>         $container = new ContainerBuilder();
>
>         $loader = new XmlFileLoader($container, new FileLocator());
>         $loader->load($cachedFile);
>
>         return $container;
>     }
>
> }
>
>

вторник, 28 августа 2012 г., 15:38:02 UTC+4 пользователь Anton Serdyuk 
написал:
>
> Hi! 
>
> AFAIK, you cannot do it in Controller, because when DI container 
> compiled, there is no more tag information in it. 
> You can find tagged services while container is compiling (in custom 
> compiler pass) and inject them all to some service like twig 
> extensions injected: 
>
> https://github.com/symfony/TwigBundle/blob/master/TwigBundle.php#L30 
>
> https://github.com/symfony/TwigBundle/blob/master/DependencyInjection/Compiler/TwigEnvironmentPass.php
>  
>
> On Tue, Aug 28, 2012 at 11:42 AM, liuggio <liu...@gmail.com <javascript:>> 
> wrote: 
> > mmmm 
> > Are you sure you really need in the controller? 
> > 
> > 
> > 
> > 
> > On Tue, Aug 28, 2012 at 9:55 AM, Ivan Lubomir 
> > <lubom...@gmail.com<javascript:>> 
> wrote: 
> >> 
> >> Hello! 
> >> 
> >> I should get list of services by tag in Controller. How to do it? 
> >> 
> >> -- 
> >> If you want to report a vulnerability issue on symfony, please send it 
> to 
> >> security at symfony-project.com 
> >> 
> >> You received this message because you are subscribed to the Google 
> >> Groups "symfony developers" group. 
> >> To post to this group, send email to 
> >> symfon...@googlegroups.com<javascript:> 
> >> To unsubscribe from this group, send email to 
> >> symfony-devs...@googlegroups.com <javascript:> 
> >> For more options, visit this group at 
> >> http://groups.google.com/group/symfony-devs?hl=en 
> > 
> > 
> > 
> > 
> > -- 
> >  __________________liuggio_________________________________ 
> > 
> >   __/|_      We reject kings, presidents and voting. 
> > /o )   \/    We believe in rough consensus 
> > )__ v _/\          and running code  (I.E.T.F. credo) 
> > ______________________________________________________________ 
> > 
> > -- 
> > If you want to report a vulnerability issue on symfony, please send it 
> to 
> > security at symfony-project.com 
> > 
> > You received this message because you are subscribed to the Google 
> > Groups "symfony developers" group. 
> > To post to this group, send email to 
> > symfon...@googlegroups.com<javascript:> 
> > To unsubscribe from this group, send email to 
> > symfony-devs...@googlegroups.com <javascript:> 
> > For more options, visit this group at 
> > http://groups.google.com/group/symfony-devs?hl=en 
>

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony developers" group.
To post to this group, send email to symfony-devs@googlegroups.com
To unsubscribe from this group, send email to
symfony-devs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/symfony-devs?hl=en

Reply via email to