當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Command\Command類代碼示例

本文整理匯總了PHP中Symfony\Component\Console\Command\Command的典型用法代碼示例。如果您正苦於以下問題:PHP Command類的具體用法?PHP Command怎麽用?PHP Command使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Command類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: configure

 /**
  * {@inheritdoc}
  */
 public function configure(Command $command)
 {
     $locatorsExamples = implode(PHP_EOL, array_map(function ($locator) {
         return '- ' . $locator;
     }, $this->specificationFinder->getExampleLocators()));
     $command->addArgument('paths', InputArgument::OPTIONAL, 'Optional path(s) to execute. Could be:' . PHP_EOL . $locatorsExamples)->addOption('--dry-run', null, InputOption::VALUE_NONE, 'Invokes formatters without executing the tests and hooks.');
 }
開發者ID:OverByThere,項目名稱:Behat,代碼行數:10,代碼來源:ExerciseController.php

示例2: execute

 public function execute()
 {
     $go = $this->getGo();
     if (!$go) {
         return $this->vars;
     }
     list($loopVarName, $loopCount) = $this->getLoopCount();
     if ($loopCount) {
         foreach ($loopCount as $loopVarValue) {
             $commandString = is_array($this->value) ? $this->value['value'] : $this->value;
             $commandArgs = explode(' ', $commandString);
             $replacedArrayArgs = array_map(function ($commandArg) use($loopVarName, $loopVarValue) {
                 return $this->replaceVarsInString($commandArg, [$loopVarName => $loopVarValue]);
             }, $commandArgs);
             $subCommand = $this->command->getApplication()->find(reset($commandArgs));
             $subCommand->run(new StringInput(implode(' ', $replacedArrayArgs)), $this->output);
         }
     } else {
         $commandString = is_array($this->value) ? $this->value['value'] : $this->value;
         $commandArgs = explode(' ', $commandString);
         $replacedArrayArgs = array_map([$this, 'replaceVarsInString'], $commandArgs);
         $subCommand = $this->command->getApplication()->find(reset($commandArgs));
         $subCommand->run(new StringInput(implode(' ', $replacedArrayArgs)), $this->output);
     }
     return $this->vars;
 }
開發者ID:lucatume,項目名稱:codeception-setup-local,代碼行數:26,代碼來源:CommandInstruction.php

示例3: getDependencies

 /**
  * @param Command $command
  * @return array
  */
 public function getDependencies(Command $command)
 {
     if (!array_key_exists($command->getName(), $this->commands)) {
         return [];
     }
     return array_keys($this->commands[$command->getName()]);
 }
開發者ID:sergeyz,項目名稱:cc,代碼行數:11,代碼來源:ChainCommandRegistry.php

示例4: assert

 /**
  * @param $condition
  * @param $message
  */
 private function assert($condition, $message)
 {
     if ($condition) {
         return;
     }
     throw new RuntimeException(sprintf('Command %s is not available because %s.', $this->command->getName(), $message));
 }
開發者ID:netz98,項目名稱:n98-magerun,代碼行數:11,代碼來源:Enabler.php

示例5: add

 /**
  * @param  Command $command
  * @return Command
  */
 public function add(Command $command)
 {
     if ($command instanceof AbstractPimpleCommand) {
         $command->setContainer($this->container);
     }
     return parent::add($command);
 }
開發者ID:saxulum,項目名稱:saxulum-console,代碼行數:11,代碼來源:ConsoleApplication.php

示例6: add

 /**
  * Add a command to the console.
  *
  * @param  \Symfony\Component\Console\Command\Command  $command
  * @return \Symfony\Component\Console\Command\Command
  */
 public function add(SymfonyCommand $command)
 {
     if ($command instanceof Command) {
         $command->setLaravel($this->laravel);
     }
     return $this->addToParent($command);
 }
開發者ID:janhartigan,項目名稱:framework,代碼行數:13,代碼來源:Application.php

示例7: simulateHelperSet

 public function simulateHelperSet(Command $command)
 {
     $this->dialog = $this->getMock("Symfony\\Component\\Console\\Helper\\DialogHelper");
     $helpers = array('dialog' => $this->dialog);
     $helperSet = new HelperSet($helpers);
     $command->setHelperSet($helperSet);
 }
開發者ID:bonndan,項目名稱:release-flow,代碼行數:7,代碼來源:CommandTest.php

示例8: add

 /**
  * Add a command to the console.
  *
  * @param  BaseCommand $command
  * @return BaseCommand
  */
 public function add(BaseCommand $command)
 {
     if ($command instanceof Command) {
         $command->setPagekit($this->pagekit);
     }
     return parent::add($command);
 }
開發者ID:enyaku,項目名稱:myGoogleMapsApiV3Test,代碼行數:13,代碼來源:Application.php

示例9: 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());
 }
開發者ID:Maksold,項目名稱:platform,代碼行數:11,代碼來源:OptionalListenersListener.php

示例10: stripOptions

 /**
  * Strip a command's options from an argv array.
  *
  * @param string[] $args
  * @param Command  $command
  *
  * @return string[]
  */
 protected function stripOptions(array $args, Command $command)
 {
     $definition = $command->getDefinition();
     foreach ($args as $key => $arg) {
         // Only consider options.
         if ($arg[0] !== '-') {
             continue;
         }
         // Look up the option. If it exists in the command definition,
         // remove it from the $args array.
         $argAsOption = preg_replace('/^\\-+([^=]+).*/', '$1', $arg);
         if ($definition->hasOption($argAsOption)) {
             $option = $definition->getOption($argAsOption);
         } else {
             try {
                 $option = $definition->getOptionForShortcut($argAsOption);
             } catch (\InvalidArgumentException $e) {
                 continue;
             }
         }
         // Unset the option.
         unset($args[$key]);
         // Unset the option's value too.
         if ($option->acceptValue() && isset($args[$key + 1]) && !strpos($arg, '=') && $args[$key + 1][0] !== '-') {
             unset($args[$key + 1]);
         }
     }
     return $args;
 }
開發者ID:drewmelck,項目名稱:platformsh-cli,代碼行數:37,代碼來源:ArgvHelper.php

示例11: add

 /**
  * @param Command $command
  * @return Command
  */
 public function add(Command $command)
 {
     if ($command instanceof ContainerAwareInterface) {
         $command->setContainer($this->container);
     }
     return parent::add($command);
 }
開發者ID:bcncommerce,項目名稱:console,代碼行數:11,代碼來源:Application.php

示例12: doRunCommand

 /**
  * @override
  * @inheritDoc
  */
 protected function doRunCommand(SymfonyCommand $command, InputInterface $input, OutputInterface $output)
 {
     if ($command instanceof CommandInterface && $command->isAsync() === true) {
         $this->async = true;
     }
     return parent::doRunCommand($command, $input, $output);
 }
開發者ID:kraken-php,項目名稱:framework,代碼行數:11,代碼來源:CommandManager.php

示例13: add

 /**
  * Add command
  *
  * @param SymfonyCommand $command
  * @return SymfonyCommand
  */
 public function add(SymfonyCommand $command)
 {
     if ($command instanceof Command) {
         $command->setConfig($this->config)->setLog($this->log);
     }
     return parent::add($command);
 }
開發者ID:Hiroto-K,項目名稱:Tw-Cron,代碼行數:13,代碼來源:Application.php

示例14: doRunCommand

 /**
  * @param Command $command
  * @param InputInterface $input
  * @param OutputInterface $output
  * @return int
  * @throws \Exception
  */
 protected function doRunCommand(Command $command, InputInterface $input, OutputInterface $output)
 {
     if ($command instanceof FactoryAwareInterface) {
         $command->setFactory($this->factory);
     }
     return parent::doRunCommand($command, $input, $output);
 }
開發者ID:TYPO3,項目名稱:Surf,代碼行數:14,代碼來源:ConsoleApplication.php

示例15: containerize_command

/**
 * @param Container $container
 * @param SymfonyCommand $command
 * @return Command|SymfonyCommand
 */
function containerize_command(Container $container, SymfonyCommand $command)
{
    if ($command instanceof Command) {
        $command->setContainer($container);
    }
    return $command;
}
開發者ID:monii,項目名稱:nimble-symfony-console,代碼行數:12,代碼來源:functions.php


注:本文中的Symfony\Component\Console\Command\Command類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。