diff --git a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/JsonDescriptor.php b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/JsonDescriptor.php
index fb4111c1c583..5e291f23a5f0 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/JsonDescriptor.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/JsonDescriptor.php
@@ -86,7 +86,7 @@ protected function describeContainerService($service, array $options = array(),
if ($service instanceof Alias) {
$this->describeContainerAlias($service, $options, $builder);
} elseif ($service instanceof Definition) {
- $this->writeData($this->getContainerDefinitionData($service), $options);
+ $this->writeData($this->getContainerDefinitionData($service, isset($options['omit_tags']) && $options['omit_tags'], isset($options['show_arguments']) && $options['show_arguments']), $options);
} else {
$this->writeData(get_class($service), $options);
}
@@ -99,6 +99,7 @@ protected function describeContainerServices(ContainerBuilder $builder, array $o
{
$serviceIds = isset($options['tag']) && $options['tag'] ? array_keys($builder->findTaggedServiceIds($options['tag'])) : $builder->getServiceIds();
$showPrivate = isset($options['show_private']) && $options['show_private'];
+ $omitTags = isset($options['omit_tags']) && $options['omit_tags'];
$showArguments = isset($options['show_arguments']) && $options['show_arguments'];
$data = array('definitions' => array(), 'aliases' => array(), 'services' => array());
@@ -109,7 +110,7 @@ protected function describeContainerServices(ContainerBuilder $builder, array $o
$data['aliases'][$serviceId] = $this->getContainerAliasData($service);
} elseif ($service instanceof Definition) {
if (($showPrivate || $service->isPublic())) {
- $data['definitions'][$serviceId] = $this->getContainerDefinitionData($service, false, $showArguments);
+ $data['definitions'][$serviceId] = $this->getContainerDefinitionData($service, $omitTags, $showArguments);
}
} else {
$data['services'][$serviceId] = get_class($service);
@@ -124,7 +125,7 @@ protected function describeContainerServices(ContainerBuilder $builder, array $o
*/
protected function describeContainerDefinition(Definition $definition, array $options = array())
{
- $this->writeData($this->getContainerDefinitionData($definition, isset($options['omit_tags']) && $options['omit_tags']), $options);
+ $this->writeData($this->getContainerDefinitionData($definition, isset($options['omit_tags']) && $options['omit_tags'], isset($options['show_arguments']) && $options['show_arguments']), $options);
}
/**
@@ -137,7 +138,7 @@ protected function describeContainerAlias(Alias $alias, array $options = array()
}
$this->writeData(
- array($this->getContainerAliasData($alias), $this->getContainerDefinitionData($builder->getDefinition((string) $alias))),
+ array($this->getContainerAliasData($alias), $this->getContainerDefinitionData($builder->getDefinition((string) $alias), isset($options['omit_tags']) && $options['omit_tags'], isset($options['show_arguments']) && $options['show_arguments'])),
array_merge($options, array('id' => (string) $alias))
);
}
diff --git a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/MarkdownDescriptor.php b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/MarkdownDescriptor.php
index 3bc82e2d7cf3..c29768e70f65 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/MarkdownDescriptor.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/MarkdownDescriptor.php
@@ -103,7 +103,7 @@ protected function describeContainerService($service, array $options = array(),
throw new \InvalidArgumentException('An "id" option must be provided.');
}
- $childOptions = array('id' => $options['id'], 'as_array' => true);
+ $childOptions = array_merge($options, array('id' => $options['id'], 'as_array' => true));
if ($service instanceof Alias) {
$this->describeContainerAlias($service, $childOptions, $builder);
diff --git a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/TextDescriptor.php b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/TextDescriptor.php
index 8ca63c07b359..b17c1e8cd0b3 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/TextDescriptor.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/TextDescriptor.php
@@ -255,8 +255,8 @@ protected function describeContainerDefinition(Definition $definition, array $op
$tableRows[] = array('Service ID', isset($options['id']) ? $options['id'] : '-');
$tableRows[] = array('Class', $definition->getClass() ?: '-');
- $tags = $definition->getTags();
- if (count($tags)) {
+ $omitTags = isset($options['omit_tags']) && $options['omit_tags'];
+ if (!$omitTags && ($tags = $definition->getTags())) {
$tagInformation = array();
foreach ($tags as $tagName => $tagData) {
foreach ($tagData as $tagParameters) {
@@ -327,6 +327,22 @@ protected function describeContainerDefinition(Definition $definition, array $op
}
}
+ $showArguments = isset($options['show_arguments']) && $options['show_arguments'];
+ $argumentsInformation = array();
+ if ($showArguments && ($arguments = $definition->getArguments())) {
+ foreach ($arguments as $argument) {
+ if ($argument instanceof Reference) {
+ $argumentsInformation[] = sprintf('Service(%s)', (string) $argument);
+ } elseif ($argument instanceof Definition) {
+ $argumentsInformation[] = 'Inlined Service';
+ } else {
+ $argumentsInformation[] = $argument;
+ }
+ }
+
+ $tableRows[] = array('Arguments', implode("\n", $argumentsInformation));
+ }
+
$options['output']->table($tableHeaders, $tableRows);
}
diff --git a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/XmlDescriptor.php b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/XmlDescriptor.php
index 82277757e04a..25505bd1130a 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/XmlDescriptor.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/XmlDescriptor.php
@@ -68,7 +68,7 @@ protected function describeContainerService($service, array $options = array(),
throw new \InvalidArgumentException('An "id" option must be provided.');
}
- $this->writeDocument($this->getContainerServiceDocument($service, $options['id'], $builder));
+ $this->writeDocument($this->getContainerServiceDocument($service, $options['id'], $builder, isset($options['show_arguments']) && $options['show_arguments']));
}
/**
@@ -84,7 +84,7 @@ protected function describeContainerServices(ContainerBuilder $builder, array $o
*/
protected function describeContainerDefinition(Definition $definition, array $options = array())
{
- $this->writeDocument($this->getContainerDefinitionDocument($definition, isset($options['id']) ? $options['id'] : null, isset($options['omit_tags']) && $options['omit_tags']));
+ $this->writeDocument($this->getContainerDefinitionDocument($definition, isset($options['id']) ? $options['id'] : null, isset($options['omit_tags']) && $options['omit_tags'], isset($options['show_arguments']) && $options['show_arguments']));
}
/**
@@ -284,7 +284,7 @@ private function getContainerServiceDocument($service, $id, ContainerBuilder $bu
if ($service instanceof Alias) {
$dom->appendChild($dom->importNode($this->getContainerAliasDocument($service, $id)->childNodes->item(0), true));
if ($builder) {
- $dom->appendChild($dom->importNode($this->getContainerDefinitionDocument($builder->getDefinition((string) $service), (string) $service)->childNodes->item(0), true));
+ $dom->appendChild($dom->importNode($this->getContainerDefinitionDocument($builder->getDefinition((string) $service), (string) $service, false, $showArguments)->childNodes->item(0), true));
}
} elseif ($service instanceof Definition) {
$dom->appendChild($dom->importNode($this->getContainerDefinitionDocument($service, $id, false, $showArguments)->childNodes->item(0), true));
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Console/Descriptor/AbstractDescriptorTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Console/Descriptor/AbstractDescriptorTest.php
index f7218e1ec0e8..ba75e7e7571b 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Console/Descriptor/AbstractDescriptorTest.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Console/Descriptor/AbstractDescriptorTest.php
@@ -79,6 +79,24 @@ public function getDescribeContainerDefinitionTestData()
return $this->getDescriptionTestData(ObjectsProvider::getContainerDefinitions());
}
+ /** @dataProvider getDescribeContainerDefinitionWithArgumentsShownTestData */
+ public function testDescribeContainerDefinitionWithArgumentsShown(Definition $definition, $expectedDescription)
+ {
+ $this->assertDescription($expectedDescription, $definition, array('show_arguments' => true));
+ }
+
+ public function getDescribeContainerDefinitionWithArgumentsShownTestData()
+ {
+ $definitions = ObjectsProvider::getContainerDefinitions();
+ $definitionsWithArgs = array();
+
+ foreach ($definitions as $key => $definition) {
+ $definitionsWithArgs[str_replace('definition_', 'definition_arguments_', $key)] = $definition;
+ }
+
+ return $this->getDescriptionTestData($definitionsWithArgs);
+ }
+
/** @dataProvider getDescribeContainerAliasTestData */
public function testDescribeContainerAlias(Alias $alias, $expectedDescription)
{
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
new file mode 100644
index 000000000000..0fd51dcde91b
--- /dev/null
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_arguments_1.json
@@ -0,0 +1,37 @@
+{
+ "class": "Full\\Qualified\\Class1",
+ "public": true,
+ "synthetic": false,
+ "lazy": true,
+ "shared": true,
+ "abstract": true,
+ "autowire": false,
+ "autowiring_types": [],
+ "arguments": [
+ {
+ "type": "service",
+ "id": "definition2"
+ },
+ "%parameter%",
+ {
+ "class": "inline_service",
+ "public": true,
+ "synthetic": false,
+ "lazy": false,
+ "shared": true,
+ "abstract": false,
+ "autowire": false,
+ "autowiring_types": [],
+ "arguments": [
+ "arg1",
+ "arg2"
+ ],
+ "file": null,
+ "tags": []
+ }
+ ],
+ "file": null,
+ "factory_class": "Full\\Qualified\\FactoryClass",
+ "factory_method": "get",
+ "tags": []
+}
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_arguments_1.md b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_arguments_1.md
new file mode 100644
index 000000000000..b4637aa023c0
--- /dev/null
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_arguments_1.md
@@ -0,0 +1,10 @@
+- Class: `Full\Qualified\Class1`
+- Public: yes
+- Synthetic: no
+- Lazy: yes
+- Shared: yes
+- Abstract: yes
+- Autowired: no
+- Arguments: yes
+- Factory Class: `Full\Qualified\FactoryClass`
+- Factory Method: `get`
\ No newline at end of file
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
new file mode 100644
index 000000000000..d6e39a5aa85a
--- /dev/null
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_arguments_1.txt
@@ -0,0 +1,20 @@
+ ------------------ -----------------------------
+ [32m Option [39m [32m Value [39m
+ ------------------ -----------------------------
+ Service ID -
+ Class Full\Qualified\Class1
+ Tags -
+ Public yes
+ Synthetic no
+ Lazy yes
+ Shared yes
+ Abstract yes
+ Autowired no
+ Autowiring Types -
+ Factory Class Full\Qualified\FactoryClass
+ Factory Method get
+ Arguments Service(definition2)
+ %parameter%
+ Inlined Service
+ ------------------ -----------------------------
+
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
new file mode 100644
index 000000000000..0acef2b14dfe
--- /dev/null
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_arguments_1.xml
@@ -0,0 +1,12 @@
+
+
+
+
+ %parameter%
+
+
+ arg1
+ arg2
+
+
+
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_arguments_2.json b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_arguments_2.json
new file mode 100644
index 000000000000..a0f6e235de62
--- /dev/null
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_arguments_2.json
@@ -0,0 +1,36 @@
+{
+ "class": "Full\\Qualified\\Class2",
+ "public": false,
+ "synthetic": true,
+ "lazy": false,
+ "shared": true,
+ "abstract": false,
+ "autowire": false,
+ "autowiring_types": [],
+ "arguments": [],
+ "file": "\/path\/to\/file",
+ "factory_service": "factory.service",
+ "factory_method": "get",
+ "calls": [
+ "setMailer"
+ ],
+ "tags": [
+ {
+ "name": "tag1",
+ "parameters": {
+ "attr1": "val1",
+ "attr2": "val2"
+ }
+ },
+ {
+ "name": "tag1",
+ "parameters": {
+ "attr3": "val3"
+ }
+ },
+ {
+ "name": "tag2",
+ "parameters": []
+ }
+ ]
+}
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_arguments_2.md b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_arguments_2.md
new file mode 100644
index 000000000000..7ffe0e551af5
--- /dev/null
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_arguments_2.md
@@ -0,0 +1,18 @@
+- Class: `Full\Qualified\Class2`
+- Public: no
+- Synthetic: yes
+- Lazy: no
+- Shared: yes
+- Abstract: no
+- Autowired: no
+- Arguments: no
+- File: `/path/to/file`
+- Factory Service: `factory.service`
+- Factory Method: `get`
+- Call: `setMailer`
+- Tag: `tag1`
+ - Attr1: val1
+ - Attr2: val2
+- Tag: `tag1`
+ - Attr3: val3
+- Tag: `tag2`
\ No newline at end of file
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_arguments_2.txt b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_arguments_2.txt
new file mode 100644
index 000000000000..cee9d8ff7d0d
--- /dev/null
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_arguments_2.txt
@@ -0,0 +1,21 @@
+ ------------------ ---------------------------------
+ [32m Option [39m [32m Value [39m
+ ------------------ ---------------------------------
+ Service ID -
+ Class Full\Qualified\Class2
+ Tags tag1 ([32mattr1[39m: val1, [32mattr2[39m: val2)
+ tag1 ([32mattr3[39m: val3)
+ tag2
+ Calls setMailer
+ Public no
+ Synthetic yes
+ Lazy no
+ Shared yes
+ Abstract no
+ Autowired no
+ Autowiring Types -
+ Required File /path/to/file
+ Factory Service factory.service
+ Factory Method get
+ ------------------ ---------------------------------
+
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_arguments_2.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_arguments_2.xml
new file mode 100644
index 000000000000..434a34b2565c
--- /dev/null
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_arguments_2.xml
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
+ val1
+ val2
+
+
+ val3
+
+
+
+