diff --git a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/JsonDescriptor.php b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/JsonDescriptor.php index 0860132ad17fc..3279bb7826198 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/JsonDescriptor.php +++ b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/JsonDescriptor.php @@ -12,6 +12,7 @@ namespace Symfony\Bundle\FrameworkBundle\Console\Descriptor; use Symfony\Component\DependencyInjection\Alias; +use Symfony\Component\DependencyInjection\Argument\ArgumentInterface; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag; @@ -227,20 +228,7 @@ private function getContainerDefinitionData(Definition $definition, $omitTags = } if ($showArguments) { - $data['arguments'] = array(); - - foreach ($definition->getArguments() as $argument) { - if ($argument instanceof Reference) { - $data['arguments'][] = array( - 'type' => 'service', - 'id' => (string) $argument, - ); - } elseif ($argument instanceof Definition) { - $data['arguments'][] = $this->getContainerDefinitionData($argument, $omitTags, $showArguments); - } else { - $data['arguments'][] = $argument; - } - } + $data['arguments'] = $this->describeValue($definition->getArguments(), $omitTags, $showArguments); } $data['file'] = $definition->getFile(); @@ -388,4 +376,33 @@ private function getCallableData($callable, array $options = array()) throw new \InvalidArgumentException('Callable is not describable.'); } + + private function describeValue($value, $omitTags, $showArguments) + { + if (is_array($value)) { + $data = array(); + foreach ($value as $k => $v) { + $data[$k] = $this->describeValue($v, $omitTags, $showArguments); + } + + return $data; + } + + if ($value instanceof Reference) { + return array( + 'type' => 'service', + 'id' => (string) $value, + ); + } + + if ($value instanceof Definition) { + return $this->getContainerDefinitionData($value, $omitTags, $showArguments); + } + + if ($value instanceof ArgumentInterface) { + return $this->describeValue($value->getValues(), $omitTags, $showArguments); + } + + return $value; + } } diff --git a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/TextDescriptor.php b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/TextDescriptor.php index bb7a76ab0c676..2adbce56c5237 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/TextDescriptor.php +++ b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/TextDescriptor.php @@ -14,6 +14,8 @@ use Symfony\Component\Console\Helper\Table; use Symfony\Component\Console\Style\SymfonyStyle; use Symfony\Component\DependencyInjection\Alias; +use Symfony\Component\DependencyInjection\Argument\ClosureProxyArgument; +use Symfony\Component\DependencyInjection\Argument\IteratorArgument; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag; @@ -325,8 +327,13 @@ protected function describeContainerDefinition(Definition $definition, array $op $argumentsInformation[] = sprintf('Service(%s)', (string) $argument); } elseif ($argument instanceof Definition) { $argumentsInformation[] = 'Inlined Service'; + } elseif ($argument instanceof IteratorArgument) { + $argumentsInformation[] = 'Iterator'; + } elseif ($argument instanceof ClosureProxyArgument) { + list($reference, $method) = $argument->getValues(); + $argumentsInformation[] = sprintf('ClosureProxy(Service(%s)::%s())', $reference, $method); } else { - $argumentsInformation[] = $argument; + $argumentsInformation[] = is_array($argument) ? 'Array' : $argument; } } diff --git a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/XmlDescriptor.php b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/XmlDescriptor.php index dd20720200a80..d0782b1ced363 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/XmlDescriptor.php +++ b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/XmlDescriptor.php @@ -12,6 +12,8 @@ namespace Symfony\Bundle\FrameworkBundle\Console\Descriptor; use Symfony\Component\DependencyInjection\Alias; +use Symfony\Component\DependencyInjection\Argument\ClosureProxyArgument; +use Symfony\Component\DependencyInjection\Argument\IteratorArgument; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag; @@ -427,6 +429,17 @@ private function getArgumentNodes(array $arguments, \DOMDocument $dom) $argumentXML->setAttribute('id', (string) $argument); } elseif ($argument instanceof Definition) { $argumentXML->appendChild($dom->importNode($this->getContainerDefinitionDocument($argument, null, false, true)->childNodes->item(0), true)); + } elseif ($argument instanceof IteratorArgument) { + $argumentXML->setAttribute('type', 'iterator'); + + foreach ($this->getArgumentNodes($argument->getValues(), $dom) as $childArgumentXML) { + $argumentXML->appendChild($childArgumentXML); + } + } elseif ($argument instanceof ClosureProxyArgument) { + list($reference, $method) = $argument->getValues(); + $argumentXML->setAttribute('type', 'closure-proxy'); + $argumentXML->setAttribute('id', (string) $reference); + $argumentXML->setAttribute('method', $method); } elseif (is_array($argument)) { $argumentXML->setAttribute('type', 'collection'); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Console/Descriptor/ObjectsProvider.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Console/Descriptor/ObjectsProvider.php index 8da498b7e43b9..0c0363c482bab 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Console/Descriptor/ObjectsProvider.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Console/Descriptor/ObjectsProvider.php @@ -12,6 +12,8 @@ namespace Symfony\Bundle\FrameworkBundle\Tests\Console\Descriptor; use Symfony\Component\DependencyInjection\Alias; +use Symfony\Component\DependencyInjection\Argument\ClosureProxyArgument; +use Symfony\Component\DependencyInjection\Argument\IteratorArgument; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag; @@ -108,6 +110,16 @@ public static function getContainerDefinitions() ->addArgument(new Reference('definition2')) ->addArgument('%parameter%') ->addArgument(new Definition('inline_service', array('arg1', 'arg2'))) + ->addArgument(array( + 'foo', + new Reference('definition2'), + new Definition('inline_service'), + )) + ->addArgument(new IteratorArgument(array( + new Reference('definition_1'), + new Reference('definition_2'), + ))) + ->addArgument(new ClosureProxyArgument('definition1', 'get')) ->setFactory(array('Full\\Qualified\\FactoryClass', 'get')), 'definition_2' => $definition2 ->setPublic(false) diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_arguments.json b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_arguments.json index 8678c9f2ccb62..7131abff99143 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_arguments.json +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_arguments.json @@ -34,7 +34,43 @@ ], "file": null, "tags": [] - } + }, + [ + "foo", + { + "type": "service", + "id": "definition2" + }, + { + "class": "inline_service", + "public": true, + "synthetic": false, + "lazy": false, + "shared": true, + "abstract": false, + "autowire": false, + "arguments": [], + "file": null, + "tags": [] + } + ], + [ + { + "type": "service", + "id": "definition_1" + }, + { + "type": "service", + "id": "definition_2" + } + ], + [ + { + "type": "service", + "id": "definition1" + }, + "get" + ] ] } }, diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_arguments.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_arguments.xml index b1c4ddfd90314..f74ad13d7be74 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_arguments.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_arguments.xml @@ -12,6 +12,18 @@ arg2 + + foo + + + + + + + + + + diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_arguments_1.json b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_arguments_1.json index 7ac1ac0ff1be7..ad4ada52a9cd4 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_arguments_1.json +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_arguments_1.json @@ -26,7 +26,43 @@ ], "file": null, "tags": [] - } + }, + [ + "foo", + { + "type": "service", + "id": "definition2" + }, + { + "class": "inline_service", + "public": true, + "synthetic": false, + "lazy": false, + "shared": true, + "abstract": false, + "autowire": false, + "arguments": [], + "file": null, + "tags": [] + } + ], + [ + { + "type": "service", + "id": "definition_1" + }, + { + "type": "service", + "id": "definition_2" + } + ], + [ + { + "type": "service", + "id": "definition1" + }, + "get" + ] ], "file": null, "factory_class": "Full\\Qualified\\FactoryClass", diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_arguments_1.txt b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_arguments_1.txt index 9d339b517e522..1c314da812d0c 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_arguments_1.txt +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_arguments_1.txt @@ -1,19 +1,22 @@ - ---------------- ----------------------------- -  Option   Value  - ---------------- ----------------------------- - Service ID - - Class Full\Qualified\Class1 - Tags - - Public yes - Synthetic no - Lazy yes - Shared yes - Abstract yes - Autowired no - Factory Class Full\Qualified\FactoryClass - Factory Method get - Arguments Service(definition2) - %parameter% - Inlined Service - ---------------- ----------------------------- + ---------------- ------------------------------------------- +  Option   Value  + ---------------- ------------------------------------------- + Service ID - + Class Full\Qualified\Class1 + Tags - + Public yes + Synthetic no + Lazy yes + Shared yes + Abstract yes + Autowired no + Factory Class Full\Qualified\FactoryClass + Factory Method get + Arguments Service(definition2) + %parameter% + Inlined Service + Array + Iterator + ClosureProxy(Service(definition1)::get()) + ---------------- ------------------------------------------- diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_arguments_1.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_arguments_1.xml index 0acef2b14dfe2..85935808c6b90 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_arguments_1.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_arguments_1.xml @@ -9,4 +9,16 @@ arg2 + + foo + + + + + + + + + +