Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 703fda3

Browse files
committed
merged branch deguif/console_xml_list_improvement (PR #8928)
This PR was squashed before being merged into the master branch (closes #8928). Discussion ---------- [Console] Improved xml generated when listing commands | Q | A | ------------- | --- | Bug fix? | no | New feature? | yes | BC breaks? | yes | Deprecations? | no | Tests pass? | yes | License | MIT I marked this PR as a BC break, as it breaks the xml schema generated by the command __app/console list --xml__ It replaces the first node (currently _symfony_) by a more generic node name ( _application_ ) and adds the application name and application version if specified in the _Symfony\Component\Console\Application_ constructor. Before (using composer console that uses symfony console component): ``` <?xml version="1.0" encoding="UTF-8"?> <symfony> ... </symfony> ``` After (using composer console that uses symfony console component): ``` <?xml version="1.0" encoding="UTF-8"?> <application name="Composer" version="x.x.x"> ... </application> ``` Commits ------- 7958227 [Console] Improved xml generated when listing commands
2 parents 2370c79 + 7958227 commit 703fda3

File tree

5 files changed

+17
-9
lines changed

5 files changed

+17
-9
lines changed

src/Symfony/Component/Console/Descriptor/XmlDescriptor.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,15 @@ public function getCommandDocument(Command $command)
9393
public function getApplicationDocument(Application $application, $namespace = null)
9494
{
9595
$dom = new \DOMDocument('1.0', 'UTF-8');
96-
$dom->appendChild($rootXml = $dom->createElement('symfony'));
96+
$dom->appendChild($rootXml = $dom->createElement('application'));
97+
98+
if ($application->getName() !== 'UNKNOWN') {
99+
$rootXml->setAttribute('name', $application->getName());
100+
if ($application->getVersion() !== 'UNKNOWN') {
101+
$rootXml->setAttribute('version', $application->getVersion());
102+
}
103+
}
104+
97105
$rootXml->appendChild($commandsXML = $dom->createElement('commands'));
98106

99107
$description = new ApplicationDescription($application, $namespace);

src/Symfony/Component/Console/Tests/Fixtures/application_1.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<symfony>
2+
<application>
33
<commands>
44
<command id="help" name="help">
55
<usage>help [--xml] [--format="..."] [--raw] [command_name]</usage>
@@ -105,4 +105,4 @@
105105
<command>list</command>
106106
</namespace>
107107
</namespaces>
108-
</symfony>
108+
</application>

src/Symfony/Component/Console/Tests/Fixtures/application_2.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<symfony>
2+
<application name="My Symfony application" version="v1.0">
33
<commands>
44
<command id="help" name="help">
55
<usage>help [--xml] [--format="..."] [--raw] [command_name]</usage>
@@ -182,4 +182,4 @@
182182
<command>descriptor:command2</command>
183183
</namespace>
184184
</namespaces>
185-
</symfony>
185+
</application>

src/Symfony/Component/Console/Tests/Fixtures/application_asxml1.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<symfony>
2+
<application>
33
<commands>
44
<command id="help" name="help">
55
<usage>help [--xml] [--format="..."] [--raw] [command_name]</usage>
@@ -141,4 +141,4 @@
141141
<command>foo:bar</command>
142142
</namespace>
143143
</namespaces>
144-
</symfony>
144+
</application>

src/Symfony/Component/Console/Tests/Fixtures/application_asxml2.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<symfony>
2+
<application>
33
<commands namespace="foo">
44
<command id="foo:bar" name="foo:bar">
55
<usage>foo:bar</usage>
@@ -34,4 +34,4 @@
3434
</options>
3535
</command>
3636
</commands>
37-
</symfony>
37+
</application>

0 commit comments

Comments
 (0)