From 45bbb5be01f0fe4198e1439c3e955ddabf591c32 Mon Sep 17 00:00:00 2001 From: Andreas Hucks Date: Mon, 12 Mar 2012 01:10:54 +0100 Subject: [PATCH] added getNativeDefinition() to allow specifying an alternate InputDefinition for help generation --- .../Component/Console/Command/Command.php | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/Console/Command/Command.php b/src/Symfony/Component/Console/Command/Command.php index 44e93af34af4..6ee48c5e65f6 100644 --- a/src/Symfony/Component/Console/Command/Command.php +++ b/src/Symfony/Component/Console/Command/Command.php @@ -298,6 +298,19 @@ public function getDefinition() return $this->definition; } + /** + * Gets the InputDefinition to be used to create XML and Text representations of this Command. + * + * Can be overridden to provide the original command representation when it would otherwise + * be changed by merging with the application InputDefinition. + * + * @return InputDefinition An InputDefinition instance + */ + protected function getNativeDefinition() + { + return $this->getDefinition(); + } + /** * Adds an argument. * @@ -531,7 +544,7 @@ public function asText() $messages[] = 'Aliases: '.implode(', ', $this->getAliases()).''; } - $messages[] = $this->definition->asText(); + $messages[] = $this->getNativeDefinition()->asText(); if ($help = $this->getProcessedHelp()) { $messages[] = 'Help:'; @@ -572,7 +585,7 @@ public function asXml($asDom = false) $aliasXML->appendChild($dom->createTextNode($alias)); } - $definition = $this->definition->asXml(true); + $definition = $this->getNativeDefinition()->asXml(true); $commandXML->appendChild($dom->importNode($definition->getElementsByTagName('arguments')->item(0), true)); $commandXML->appendChild($dom->importNode($definition->getElementsByTagName('options')->item(0), true));