Bläddra i källkod

added getNativeDefinition() to allow specifying an alternate InputDefinition for help generation

Andreas Hucks 13 år sedan
förälder
incheckning
45bbb5be01
1 ändrade filer med 15 tillägg och 2 borttagningar
  1. 15 2
      src/Symfony/Component/Console/Command/Command.php

+ 15 - 2
src/Symfony/Component/Console/Command/Command.php

@@ -298,6 +298,19 @@ class Command
         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 @@ class Command
             $messages[] = '<comment>Aliases:</comment> <info>'.implode(', ', $this->getAliases()).'</info>';
         }
 
-        $messages[] = $this->definition->asText();
+        $messages[] = $this->getNativeDefinition()->asText();
 
         if ($help = $this->getProcessedHelp()) {
             $messages[] = '<comment>Help:</comment>';
@@ -572,7 +585,7 @@ class Command
             $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));