findTags() public method

Returns all tags the defined services use.
public findTags ( ) : array
return array An array of tags
 public function testServicesDefinitionTest()
 {
     $this->createFullConfiguration();
     $tags = $this->configuration->findTags();
     $this->assertEquals('form.type', $tags[0]);
     $taggedServices = $this->configuration->findTaggedServiceIds($tags[0]);
     $this->assertTrue(isset($taggedServices['acme_cart.cart.form.type']));
     $this->assertEquals('leaphly_cart', $taggedServices['acme_cart.cart.form.type'][0]['alias']);
     $this->assertTrue(isset($taggedServices['acme_cart.cart.limited.form.type']));
     $this->assertEquals('leaphly_cart_limited', $taggedServices['acme_cart.cart.limited.form.type'][0]['alias']);
 }
 /**
  * Renders list of tagged services grouped by tag.
  *
  * @param OutputInterface $output
  * @param bool            $showPrivate
  */
 protected function outputTags(OutputInterface $output, $showPrivate = false)
 {
     $tags = $this->containerBuilder->findTags();
     asort($tags);
     $label = 'Tagged services';
     $output->writeln($this->getHelper('formatter')->formatSection('container', $label));
     foreach ($tags as $tag) {
         $serviceIds = $this->containerBuilder->findTaggedServiceIds($tag);
         foreach ($serviceIds as $serviceId => $attributes) {
             $definition = $this->resolveServiceDefinition($serviceId);
             if ($definition instanceof Definition) {
                 if (!$showPrivate && !$definition->isPublic()) {
                     unset($serviceIds[$serviceId]);
                     continue;
                 }
             }
         }
         if (count($serviceIds) === 0) {
             continue;
         }
         $output->writeln($this->getHelper('formatter')->formatSection('tag', $tag));
         foreach ($serviceIds as $serviceId => $attributes) {
             $output->writeln($serviceId);
         }
         $output->writeln('');
     }
 }
Example #3
0
 public function process(ContainerBuilder $container)
 {
     $compiler = $container->getCompiler();
     $formatter = $compiler->getLoggingFormatter();
     $tags = array_unique(array_merge($container->findTags(), $this->whitelist));
     foreach ($container->findUnusedTags() as $tag) {
         // skip whitelisted tags
         if (in_array($tag, $this->whitelist)) {
             continue;
         }
         // check for typos
         $candidates = array();
         foreach ($tags as $definedTag) {
             if ($definedTag === $tag) {
                 continue;
             }
             if (false !== strpos($definedTag, $tag) || levenshtein($tag, $definedTag) <= strlen($tag) / 3) {
                 $candidates[] = $definedTag;
             }
         }
         $services = array_keys($container->findTaggedServiceIds($tag));
         $message = sprintf('Tag "%s" was defined on service(s) "%s", but was never used.', $tag, implode('", "', $services));
         if (!empty($candidates)) {
             $message .= sprintf(' Did you mean "%s"?', implode('", "', $candidates));
         }
         $compiler->addLogMessage($formatter->format($this, $message));
     }
 }
Example #4
0
    protected function addCustom($options)
    {
        $tags = array();
        foreach ($this->container->findTags() as $tag) {
            $tags[$tag] = array_keys($this->container->findTaggedServiceIds($tag));
        }
        $configurations = array();
        $disabled = array();
        foreach ($options['nucleus']['services'] as $serviceName => $serviceDefinition) {
            $configurations[$serviceName] = null;
            if (isset($serviceDefinition['disabled']) && $serviceDefinition['disabled']) {
                $disabled[] = $serviceName;
            }
            if (isset($serviceDefinition['configuration'])) {
                $configurations[$serviceName] = $serviceDefinition['configuration'];
            }
        }
        return '
    protected $tags = ' . var_export($tags, true) . ';
      
    protected $disabled = ' . var_export($disabled, true) . ';
';
    }
Example #5
0
 /**
  * @param ContainerBuilder $builder
  * @param bool             $showPrivate
  *
  * @return array
  */
 protected function findDefinitionsByTag(ContainerBuilder $builder, $showPrivate)
 {
     $definitions = array();
     $tags = $builder->findTags();
     asort($tags);
     foreach ($tags as $tag) {
         foreach ($builder->findTaggedServiceIds($tag) as $serviceId => $attributes) {
             $definition = $this->resolveServiceDefinition($builder, $serviceId);
             if (!$definition instanceof Definition || !$showPrivate && !$definition->isPublic()) {
                 continue;
             }
             if (!isset($definitions[$tag])) {
                 $definitions[$tag] = array();
             }
             $definitions[$tag][$serviceId] = $definition;
         }
     }
     return $definitions;
 }
Example #6
0
 /**
  * Returns all tags the defined services use.
  *
  * @return array An array of tags
  *
  * @api
  * @since 4.0.0
  */
 public function findTags()
 {
     return $this->_delegateContainerBuilder->findTags();
 }