本文整理汇总了PHP中Symfony\Component\Console\Command\Command::mergeApplicationDefinition方法的典型用法代码示例。如果您正苦于以下问题:PHP Command::mergeApplicationDefinition方法的具体用法?PHP Command::mergeApplicationDefinition怎么用?PHP Command::mergeApplicationDefinition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\Console\Command\Command
的用法示例。
在下文中一共展示了Command::mergeApplicationDefinition方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addOptionsToCommand
/**
* @param Command $command
* @param InputInterface $input
*/
protected function addOptionsToCommand(Command $command, InputInterface $input)
{
$inputDefinition = $command->getApplication()->getDefinition();
$inputDefinition->addOption(new InputOption(self::DISABLE_OPTIONAL_LISTENERS, null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, sprintf('Disable optional listeners, "%s" to disable all listeners, ' . 'command "%s" shows all listeners', self::ALL_OPTIONAL_LISTENERS_VALUE, OptionalListenersCommand::NAME)));
$command->mergeApplicationDefinition();
$input->bind($command->getDefinition());
}
示例2: describeCommand
/**
* @inheritdoc
*/
protected function describeCommand(Command $command, array $options = [])
{
$command->getSynopsis();
$command->mergeApplicationDefinition(false);
$this->write($command->getName() . "\n" . str_repeat('-', strlen($command->getName())) . "\n");
if ($description = $command->getDescription()) {
$this->write("{$description}\n\n");
}
$aliases = $command instanceof CommandBase ? $command->getVisibleAliases() : $command->getAliases();
if ($aliases) {
$this->write('Aliases: ' . '`' . implode('`, `', $aliases) . '`' . "\n\n");
}
$executableName = 'platform';
$this->write("## Usage:\n\n```\n{$executableName} " . $command->getSynopsis() . "\n```\n\n");
if ($help = $command->getProcessedHelp()) {
$this->write($help);
$this->write("\n\n");
}
if ($command->getNativeDefinition()) {
$this->describeInputDefinition($command->getNativeDefinition());
$this->write("\n\n");
}
if ($command instanceof CommandBase && ($examples = $command->getExamples())) {
$this->write('## Examples');
$this->write("\n");
$name = $command->getName();
foreach ($examples as $arguments => $description) {
$this->write("\n* {$description}: \n ```\n platform {$name} {$arguments}\n ```\n");
}
$this->write("\n");
}
}
示例3: describeCommand
/**
* @inheritdoc
*/
protected function describeCommand(Command $command, array $options = array())
{
$command->getSynopsis();
$command->mergeApplicationDefinition(false);
$this->writeText("<comment>Command:</comment> " . $command->getName(), $options);
if ($aliases = $command->getAliases()) {
$this->writeText("\n");
$this->writeText('<comment>Aliases:</comment> ' . implode(', ', $aliases), $options);
}
if ($description = $command->getDescription()) {
$this->writeText("\n");
$this->writeText("<comment>Description:</comment> {$description}", $options);
}
$this->writeText("\n\n");
$this->writeText('<comment>Usage:</comment>', $options);
$this->writeText("\n");
$this->writeText(' ' . $command->getSynopsis(), $options);
$this->writeText("\n");
if ($definition = $command->getNativeDefinition()) {
$this->writeText("\n");
$this->describeInputDefinition($definition, $options);
}
if ($help = $command->getProcessedHelp()) {
$this->writeText("\n");
$this->writeText('<comment>Help:</comment>', $options);
$this->writeText("\n");
$this->writeText(' ' . str_replace("\n", "\n ", $help), $options);
$this->writeText("\n");
}
}
示例4: updateCommandDefinition
private function updateCommandDefinition(Command $command, OutputInterface $output)
{
$eventDispatcher = $this->getApplication()->getDispatcher();
$input = new ArrayInput(['command' => $command->getName()]);
$event = new ConsoleCommandEvent($command, $input, $output);
$eventDispatcher->dispatch(GushEvents::DECORATE_DEFINITION, $event);
$command->getSynopsis(true);
$command->getSynopsis(false);
$command->mergeApplicationDefinition();
try {
$input->bind($command->getDefinition());
} catch (\Exception $e) {
$output->writeln('<error>Something went wrong: </error>' . $e->getMessage());
return;
}
$eventDispatcher->dispatch(GushEvents::INITIALIZE, $event);
// The options were set on the input but now we need to set them on the Command definition
if ($options = $input->getOptions()) {
foreach ($options as $name => $value) {
$option = $command->getDefinition()->getOption($name);
if ($option->acceptValue()) {
$option->setDefault($value);
}
}
}
}
示例5: describeCommand
protected function describeCommand(Command $command, array $options = array())
{
$command->getSynopsis(true);
$command->getSynopsis(false);
$command->mergeApplicationDefinition(false);
$this->writeText('<comment>Usage:</comment>', $options);
foreach (array_merge(array($command->getSynopsis(true)), $command->getAliases(), $command->getUsages()) as $usage) {
$this->writeText("\n");
$this->writeText(' ' . $usage, $options);
}
$this->writeText("\n");
$definition = $command->getNativeDefinition();
if ($definition->getOptions() || $definition->getArguments()) {
$this->writeText("\n");
$this->describeInputDefinition($definition, $options);
$this->writeText("\n");
}
if ($help = $command->getProcessedHelp()) {
$this->writeText("\n");
$this->writeText('<comment>Help:</comment>', $options);
$this->writeText("\n");
$this->writeText(' ' . str_replace("\n", "\n ", $help), $options);
$this->writeText("\n");
}
}
示例6: mergeApplicationDefinition
/**
* Remove workflow option
*
* @param bool $mergeArgs mergeArgs
*
* @return void
*/
public function mergeApplicationDefinition($mergeArgs = true)
{
parent::mergeApplicationDefinition($mergeArgs);
$options = array();
foreach ($this->getDefinition()->getOptions() as $option) {
if ($option->getName() !== 'workflow') {
$options[] = $option;
}
}
$this->getDefinition()->setOptions($options);
}
示例7: describeCommand
/**
* {@inheritdoc}
*/
protected function describeCommand(Command $command, array $options = array())
{
$command->getSynopsis();
$command->mergeApplicationDefinition(false);
$markdown = $command->getName() . "\n" . str_repeat('-', strlen($command->getName())) . "\n\n" . '* Description: ' . ($command->getDescription() ?: '<none>') . "\n" . '* Usage: `' . $command->getSynopsis() . '`' . "\n" . '* Aliases: ' . (count($command->getAliases()) ? '`' . implode('`, `', $command->getAliases()) . '`' : '<none>');
if ($help = $command->getProcessedHelp()) {
$markdown .= "\n\n" . $help;
}
if ($definitionMarkdown = $this->describeInputDefinition($command->getNativeDefinition())) {
$markdown .= "\n\n" . $definitionMarkdown;
}
return $markdown;
}
示例8: describeCommand
/**
* {@inheritdoc}
*/
protected function describeCommand(Command $command, array $options = array())
{
$command->getSynopsis();
$command->mergeApplicationDefinition(false);
$this->write($command->getName() . "\n" . str_repeat('-', strlen($command->getName())) . "\n\n" . '* Description: ' . ($command->getDescription() ?: '<none>') . "\n" . '* Usage:' . "\n\n" . array_reduce(array_merge(array($command->getSynopsis()), $command->getAliases(), $command->getUsages()), function ($carry, $usage) {
return $carry .= ' * `' . $usage . '`' . "\n";
}));
if ($help = $command->getProcessedHelp()) {
$this->write("\n");
$this->write($help);
}
if ($command->getNativeDefinition()) {
$this->write("\n\n");
$this->describeInputDefinition($command->getNativeDefinition());
}
}
示例9: getCommandDocument
/**
* @param Command $command
*
* @return \DOMDocument
*/
public function getCommandDocument(Command $command)
{
$dom = new \DOMDocument('1.0', 'UTF-8');
$dom->appendChild($commandXML = $dom->createElement('command'));
$command->getSynopsis();
$command->mergeApplicationDefinition(false);
$commandXML->setAttribute('id', $command->getName());
$commandXML->setAttribute('name', $command->getName());
$commandXML->appendChild($usagesXML = $dom->createElement('usages'));
foreach (array_merge(array($command->getSynopsis()), $command->getAliases(), $command->getUsages()) as $usage) {
$usagesXML->appendChild($dom->createElement('usage', $usage));
}
$commandXML->appendChild($descriptionXML = $dom->createElement('description'));
$descriptionXML->appendChild($dom->createTextNode(str_replace("\n", "\n ", $command->getDescription())));
$commandXML->appendChild($helpXML = $dom->createElement('help'));
$helpXML->appendChild($dom->createTextNode(str_replace("\n", "\n ", $command->getProcessedHelp())));
$definitionXML = $this->getInputDefinitionDocument($command->getNativeDefinition());
$this->appendDocument($commandXML, $definitionXML->getElementsByTagName('definition')->item(0));
return $dom;
}
示例10: describeCommand
/**
* @inheritdoc
*/
protected function describeCommand(Command $command, array $options = [])
{
$command->getSynopsis();
$command->mergeApplicationDefinition(false);
$this->writeText("<comment>Command:</comment> " . $command->getName(), $options);
$aliases = $command instanceof CommandBase ? $command->getVisibleAliases() : $command->getAliases();
if ($aliases) {
$this->writeText("\n");
$this->writeText('<comment>Aliases:</comment> ' . implode(', ', $aliases), $options);
}
if ($description = $command->getDescription()) {
$this->writeText("\n");
$this->writeText("<comment>Description:</comment> {$description}", $options);
}
$this->writeText("\n\n");
$this->writeText('<comment>Usage:</comment>', $options);
$this->writeText("\n");
$executableName = 'platform';
$this->writeText(' ' . $executableName . ' ' . $command->getSynopsis(), $options);
$this->writeText("\n");
if ($definition = $command->getNativeDefinition()) {
$this->writeText("\n");
$this->describeInputDefinition($definition, $options);
$this->writeText("\n");
}
if ($help = $command->getProcessedHelp()) {
$this->writeText("\n");
$this->writeText('<comment>Help:</comment>', $options);
$this->writeText("\n");
$this->writeText(' ' . str_replace("\n", "\n ", $help), $options);
$this->writeText("\n");
}
if ($command instanceof CommandBase && ($examples = $command->getExamples())) {
$this->writeText("\n");
$this->writeText('<comment>Examples:</comment>', $options);
$name = $command->getName();
foreach ($examples as $arguments => $description) {
$this->writeText("\n {$description}:\n <info>platform {$name} {$arguments}</info>\n");
}
}
}
示例11: describeCommand
/**
* {@inheritdoc}
*/
protected function describeCommand(Command $command, array $options = array())
{
$command->getSynopsis();
$command->mergeApplicationDefinition(false);
return $this->output(array('name' => $command->getName(), 'usage' => $command->getSynopsis(), 'description' => $command->getDescription(), 'help' => $command->getProcessedHelp(), 'aliases' => $command->getAliases(), 'definition' => $this->describeInputDefinition($command->getNativeDefinition(), array('as_array' => true))), $options);
}
示例12: getCommandData
/**
* @param Command $command
*
* @return array
*/
private function getCommandData(Command $command)
{
$command->getSynopsis();
$command->mergeApplicationDefinition(false);
return array('name' => $command->getName(), 'usage' => array_merge(array($command->getSynopsis()), $command->getUsages(), $command->getAliases()), 'description' => $command->getDescription(), 'help' => $command->getProcessedHelp(), 'definition' => $this->getInputDefinitionData($command->getNativeDefinition()));
}
示例13: doRunCommand
/**
* Runs the current command.
*
* If an event dispatcher has been attached to the application,
* events are also dispatched during the life-cycle of the command.
*
* @param Command $command A Command instance
* @param InputInterface $input An Input instance
* @param OutputInterface $output An Output instance
*
* @return int 0 if everything went fine, or an error code
*
* @throws \Exception when the command being run threw an exception
*/
protected function doRunCommand(Command $command, InputInterface $input, OutputInterface $output)
{
foreach ($command->getHelperSet() as $helper) {
if ($helper instanceof InputAwareInterface) {
$helper->setInput($input);
}
}
if (null === $this->dispatcher) {
return $command->run($input, $output);
}
// bind before the console.command event, so the listeners have access to input options/arguments
try {
$command->mergeApplicationDefinition();
$input->bind($command->getDefinition());
} catch (ExceptionInterface $e) {
// ignore invalid options/arguments for now, to allow the event listeners to customize the InputDefinition
}
$event = new ConsoleCommandEvent($command, $input, $output);
$this->dispatcher->dispatch(ConsoleEvents::COMMAND, $event);
if ($event->commandShouldRun()) {
try {
$exitCode = $command->run($input, $output);
} catch (\Exception $e) {
$event = new ConsoleExceptionEvent($command, $input, $output, $e, $e->getCode());
$this->dispatcher->dispatch(ConsoleEvents::EXCEPTION, $event);
$e = $event->getException();
$event = new ConsoleTerminateEvent($command, $input, $output, $e->getCode());
$this->dispatcher->dispatch(ConsoleEvents::TERMINATE, $event);
throw $e;
}
} else {
$exitCode = ConsoleCommandEvent::RETURN_CODE_DISABLED;
}
$event = new ConsoleTerminateEvent($command, $input, $output, $exitCode);
$this->dispatcher->dispatch(ConsoleEvents::TERMINATE, $event);
return $event->getExitCode();
}
示例14: mergeApplicationDefinition
/**
* {@inheritdoc}
*/
public function mergeApplicationDefinition($mergeArgs = true)
{
$this->decoratedCommand->mergeApplicationDefinition($mergeArgs);
}
示例15: mergeApplicationDefinition
public function mergeApplicationDefinition($mergeArgs = true)
{
return $this->innerCommand->mergeApplicationDefinition($mergeArgs);
}