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
This commit is contained in:
Fabien Potencier 2013-09-07 18:43:43 +02:00
commit 703fda3b8b
5 changed files with 17 additions and 9 deletions

View File

@ -93,7 +93,15 @@ class XmlDescriptor extends Descriptor
public function getApplicationDocument(Application $application, $namespace = null)
{
$dom = new \DOMDocument('1.0', 'UTF-8');
$dom->appendChild($rootXml = $dom->createElement('symfony'));
$dom->appendChild($rootXml = $dom->createElement('application'));
if ($application->getName() !== 'UNKNOWN') {
$rootXml->setAttribute('name', $application->getName());
if ($application->getVersion() !== 'UNKNOWN') {
$rootXml->setAttribute('version', $application->getVersion());
}
}
$rootXml->appendChild($commandsXML = $dom->createElement('commands'));
$description = new ApplicationDescription($application, $namespace);

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<symfony>
<application>
<commands>
<command id="help" name="help">
<usage>help [--xml] [--format="..."] [--raw] [command_name]</usage>
@ -105,4 +105,4 @@
<command>list</command>
</namespace>
</namespaces>
</symfony>
</application>

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<symfony>
<application name="My Symfony application" version="v1.0">
<commands>
<command id="help" name="help">
<usage>help [--xml] [--format="..."] [--raw] [command_name]</usage>
@ -182,4 +182,4 @@
<command>descriptor:command2</command>
</namespace>
</namespaces>
</symfony>
</application>

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<symfony>
<application>
<commands>
<command id="help" name="help">
<usage>help [--xml] [--format="..."] [--raw] [command_name]</usage>
@ -141,4 +141,4 @@
<command>foo:bar</command>
</namespace>
</namespaces>
</symfony>
</application>

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<symfony>
<application>
<commands namespace="foo">
<command id="foo:bar" name="foo:bar">
<usage>foo:bar</usage>
@ -34,4 +34,4 @@
</options>
</command>
</commands>
</symfony>
</application>