本文整理汇总了PHP中Symfony\Component\Console\Command\Command::setDefinition方法的典型用法代码示例。如果您正苦于以下问题:PHP Command::setDefinition方法的具体用法?PHP Command::setDefinition怎么用?PHP Command::setDefinition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\Console\Command\Command
的用法示例。
在下文中一共展示了Command::setDefinition方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: generateCommand
/**
* 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;
}
示例2: buildCommand
/**
* Build a Symfony Console commands.
*
* @param \Yosymfony\Spress\Plugin\CommandPluginInterface $commandPlugin
*
* @return \Symfony\Component\Console\Command\Command Symfony Console command.
*/
protected function buildCommand(CommandPluginInterface $commandPlugin)
{
$definition = $commandPlugin->getCommandDefinition();
$argumentsAndOptions = [];
$consoleComand = new Command($definition->getName());
$consoleComand->setDescription($definition->getDescription());
$consoleComand->setHelp($definition->getHelp());
foreach ($definition->getArguments() as list($name, $mode, $description, $defaultValue)) {
$argumentsAndOptions[] = new InputArgument($name, $mode, $description, $defaultValue);
}
foreach ($definition->getOptions() as list($name, $shortcut, $mode, $description, $defaultValue)) {
$argumentsAndOptions[] = new InputOption($name, $shortcut, $mode, $description, $defaultValue);
}
$consoleComand->setDefinition($argumentsAndOptions);
$consoleComand->setCode(function (InputInterface $input, OutputInterface $output) use($commandPlugin) {
$io = new ConsoleIO($input, $output);
$arguments = $input->getArguments();
$options = $input->getOptions();
$commandPlugin->executeCommand($io, $arguments, $options);
});
return $consoleComand;
}
示例3: setDefinition
/**
* {@inheritdoc}
*/
public function setDefinition($definition)
{
$this->decoratedCommand->setDefinition($definition);
return $this;
}
示例4: setDefinition
public function setDefinition($definition)
{
return $this->innerCommand->setDefinition($definition);
}
示例5: setInputDefinition
/**
* @param Command $command
* @param InputInterface $input
* @param InputDefinition $inputDefinition
*/
private function setInputDefinition(Command $command, InputInterface $input, InputDefinition $inputDefinition)
{
$command->setDefinition($inputDefinition);
$command->mergeApplicationDefinition();
$input->bind($inputDefinition);
}
开发者ID:bangpound,项目名称:symfony-console-form,代码行数:11,代码来源:SetInputDefinitionOfFormBasedCommandEventListener.php