Symfony\Component\DependencyInjection\Definition::getTags PHP Method

getTags() public method

Returns all tags.
public getTags ( ) : array
return array An array of tags
    public function getTags()
    {
        return $this->tags;
    }

Usage Example

Example #1
0
 /**
  * Adds a service
  *
  * @param string     $id
  * @param Definition $definition
  *
  * @return string
  */
 private function addService($id, $definition)
 {
     $code = "    {$id}:\n";
     if ($definition->getClass()) {
         $code .= sprintf("        class: %s\n", $definition->getClass());
     }
     $tagsCode = '';
     foreach ($definition->getTags() as $name => $tags) {
         foreach ($tags as $attributes) {
             $att = array();
             foreach ($attributes as $key => $value) {
                 $att[] = sprintf('%s: %s', $this->dumper->dump($key), $this->dumper->dump($value));
             }
             $att = $att ? ', ' . implode(' ', $att) : '';
             $tagsCode .= sprintf("            - { name: %s%s }\n", $this->dumper->dump($name), $att);
         }
     }
     if ($tagsCode) {
         $code .= "        tags:\n" . $tagsCode;
     }
     if ($definition->getFile()) {
         $code .= sprintf("        file: %s\n", $definition->getFile());
     }
     if ($definition->isSynthetic()) {
         $code .= sprintf("        synthetic: true\n");
     }
     if ($definition->isSynchronized()) {
         $code .= sprintf("        synchronized: true\n");
     }
     if ($definition->getFactoryMethod()) {
         $code .= sprintf("        factory_method: %s\n", $definition->getFactoryMethod());
     }
     if ($definition->getFactoryService()) {
         $code .= sprintf("        factory_service: %s\n", $definition->getFactoryService());
     }
     if ($definition->getArguments()) {
         $code .= sprintf("        arguments: %s\n", $this->dumper->dump($this->dumpValue($definition->getArguments()), 0));
     }
     if ($definition->getProperties()) {
         $code .= sprintf("        properties: %s\n", $this->dumper->dump($this->dumpValue($definition->getProperties()), 0));
     }
     if ($definition->getMethodCalls()) {
         $code .= sprintf("        calls:\n%s\n", $this->dumper->dump($this->dumpValue($definition->getMethodCalls()), 1, 12));
     }
     if (ContainerInterface::SCOPE_CONTAINER !== ($scope = $definition->getScope())) {
         $code .= sprintf("        scope: %s\n", $scope);
     }
     if ($callable = $definition->getConfigurator()) {
         if (is_array($callable)) {
             if ($callable[0] instanceof Reference) {
                 $callable = array($this->getServiceCall((string) $callable[0], $callable[0]), $callable[1]);
             } else {
                 $callable = array($callable[0], $callable[1]);
             }
         }
         $code .= sprintf("        configurator: %s\n", $this->dumper->dump($callable, 0));
     }
     return $code;
 }
All Usage Examples Of Symfony\Component\DependencyInjection\Definition::getTags