本文整理匯總了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