Skip to content

Commit

Permalink
Fix wrong method in findTaggedServiceIds(), add example to docblock.
Browse files Browse the repository at this point in the history
  • Loading branch information
beberlei authored and fabpot committed May 3, 2013
1 parent 0306957 commit cfebe47
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/Symfony/Component/DependencyInjection/ContainerBuilder.php
Expand Up @@ -848,17 +848,28 @@ public function resolveServices($value)
/**
* 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
*/
public function findTaggedServiceIds($name)
{
$tags = array();
foreach ($this->getDefinitions() as $id => $definition) {
if ($definition->getTag($name)) {
if ($definition->hasTag($name)) {
$tags[$id] = $definition->getTag($name);
}
}
Expand Down

0 comments on commit cfebe47

Please sign in to comment.