Fix wrong method in findTaggedServiceIds(), add example to docblock.

This commit is contained in:
Benjamin Eberlei 2013-05-02 19:49:45 +02:00 committed by Fabien Potencier
parent 030695752b
commit cfebe47000

View File

@ -848,9 +848,20 @@ class ContainerBuilder extends Container implements TaggedContainerInterface
/** /**
* Returns service ids for a given tag. * 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 * @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 * @api
*/ */
@ -858,7 +869,7 @@ class ContainerBuilder extends Container implements TaggedContainerInterface
{ {
$tags = array(); $tags = array();
foreach ($this->getDefinitions() as $id => $definition) { foreach ($this->getDefinitions() as $id => $definition) {
if ($definition->getTag($name)) { if ($definition->hasTag($name)) {
$tags[$id] = $definition->getTag($name); $tags[$id] = $definition->getTag($name);
} }
} }