Symfony\Component\Console\Command\Command::setDefinition PHP Method

setDefinition() public method

Sets an array of argument and option instances.
public setDefinition ( array | Symfony\Component\Console\Input\InputDefinition $definition ) : Command
$definition array | Symfony\Component\Console\Input\InputDefinition An array of argument and option instances or a definition instance
return Command The current instance
    public function setDefinition($definition)
    {
        if ($definition instanceof InputDefinition) {
            $this->definition = $definition;
        } else {
            $this->definition->setDefinition($definition);
        }
        $this->applicationDefinitionMerged = false;
        return $this;
    }

Usage Example

 /**
  * creates a Command based on an Api Method.
  *
  * @param string            $name
  * @param \ReflectionMethod $method
  * @param string            $token
  *
  * @return Command
  */
 private function generateCommand($name, \ReflectionMethod $method, $token = null)
 {
     $methodName = $this->transformer->transform($method->getName());
     $command = new Command(strtolower($name . ':' . $methodName));
     $docBlock = DocBlockFactory::createInstance()->create($method->getDocComment());
     $command->setDefinition($this->buildDefinition($method, $token));
     $command->setDescription($docBlock->getSummary());
     $command->setCode($this->createCode($name, $method));
     return $command;
 }
All Usage Examples Of Symfony\Component\Console\Command\Command::setDefinition