From cfebe47000d2a56129d1f953c4fb489aeb3e532a Mon Sep 17 00:00:00 2001 From: Benjamin Eberlei Date: Thu, 2 May 2013 19:49:45 +0200 Subject: [PATCH] Fix wrong method in findTaggedServiceIds(), add example to docblock. --- .../DependencyInjection/ContainerBuilder.php | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/DependencyInjection/ContainerBuilder.php b/src/Symfony/Component/DependencyInjection/ContainerBuilder.php index a43e08c7fe..0bff46a2d7 100644 --- a/src/Symfony/Component/DependencyInjection/ContainerBuilder.php +++ b/src/Symfony/Component/DependencyInjection/ContainerBuilder.php @@ -848,9 +848,20 @@ class ContainerBuilder extends Container implements TaggedContainerInterface /** * Returns service ids for a given tag. * + * Example: + * + * $container->register('foo')->addTag('my.tag', array('hello' => 'world')); + * + * $serviceIds = $container->findTaggedServiceIds('my.tag'); + * foreach ($serviceIds as $serviceId => $tags) { + * foreach ($tags as $tag) { + * echo $tag['hello']; + * } + * } + * * @param string $name The tag name * - * @return array An array of tags + * @return array An array of tags with the tagged service as key, holding a list of attribute arrays. * * @api */ @@ -858,7 +869,7 @@ class ContainerBuilder extends Container implements TaggedContainerInterface { $tags = array(); foreach ($this->getDefinitions() as $id => $definition) { - if ($definition->getTag($name)) { + if ($definition->hasTag($name)) { $tags[$id] = $definition->getTag($name); } }