You are here

public function ContainerBuilder::findTaggedServiceIds in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/symfony/dependency-injection/ContainerBuilder.php \Symfony\Component\DependencyInjection\ContainerBuilder::findTaggedServiceIds()

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']; } }

Parameters

string $name The tag name:

Return value

array An array of tags with the tagged service as key, holding a list of attribute arrays.

Overrides TaggedContainerInterface::findTaggedServiceIds

File

vendor/symfony/dependency-injection/ContainerBuilder.php, line 973

Class

ContainerBuilder
ContainerBuilder is a DI container that provides an API to easily describe services.

Namespace

Symfony\Component\DependencyInjection

Code

public function findTaggedServiceIds($name) {
  $tags = array();
  foreach ($this
    ->getDefinitions() as $id => $definition) {
    if ($definition
      ->hasTag($name)) {
      $tags[$id] = $definition
        ->getTag($name);
    }
  }
  return $tags;
}