本文整理汇总了PHP中Symfony\Component\Console\Command\Command::getHelper方法的典型用法代码示例。如果您正苦于以下问题:PHP Command::getHelper方法的具体用法?PHP Command::getHelper怎么用?PHP Command::getHelper使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\Console\Command\Command
的用法示例。
在下文中一共展示了Command::getHelper方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: it_opens_a_dialog_to_select_the_entity_and_count_if_no_entity_given
/** @test */
public function it_opens_a_dialog_to_select_the_entity_and_count_if_no_entity_given()
{
/** @var SymfonyQuestionHelper $question */
$question = $this->command->getHelper('question');
$question->setInputStream($this->getInputStream("1\n5\n"));
$this->commandTester->execute(['command' => $this->command->getName()]);
$count = $this->getDatabaseCount(App::class, []);
$this->assertEquals(5, $count);
$this->assertContains(sprintf('%s seeded.', App::class), $this->commandTester->getDisplay());
}
示例2: createPlayerDialog
public function createPlayerDialog(Command $command, OutputInterface $output)
{
/** @var $dialog DialogHelper */
$dialog = $command->getHelperSet()->get("dialog");
/** @var $translations TranslationsHelperInterface */
$translations = $command->getHelper("translations");
$player = new PlayerDataHelper();
$player->name = $dialog->ask($output, $translations->getLine("player_name") . ": ");
$player->sex = $dialog->ask($output, $translations->getLine("player_sex_cmd") . ": ");
$player->class = $dialog->ask($output, $translations->getLine("player_class_cmd") . ": ");
$player->race = $dialog->ask($output, $translations->getLine("player_race_cmd") . ": ");
return $player;
}
示例3: render
public function render($results, Command $command)
{
$phpVersion = $this->getOption('phpVersion');
$checksCount = $this->getOption('checksCount');
$failCount = $this->getOption('failCount');
$output = $this->getOutput();
$output->writeLn('Executing against version: ' . $phpVersion);
$table = $command->getHelper('table');
$table->setHeaders(array('Status', 'CVE ID', 'Risk', 'Summary'));
$columnSize = 100;
for ($i = 0, $length = count($results); $i < $length; $i++) {
$results[$i]['status'] = 'fail' ? '<fg=red>FAIL</fg=red>' : '<fg=green>PASS</fg=green>';
$results[$i]['summary'] = !$output->isVerbose() && strlen($results[$i]['summary']) > $columnSize ? substr($results[$i]['summary'], 0, $columnSize - 3) . '...' : $results[$i]['summary'];
}
$table->setRows($results);
$table->render($output);
$output->writeLn(sprintf("\nScan complete\n%s\nTotal checks: %s\n<fg=red>Failures: %s</fg=red>\n", str_repeat('-', 20), $checksCount, $failCount));
}
示例4: getHelper
/**
* {@inheritdoc}
*/
public function getHelper($name)
{
return $this->decoratedCommand->getHelper($name);
}
示例5: testCommandWithWrongInputsNumber
/**
* @expectedException \RuntimeException
* @expectedMessage Aborted
*/
public function testCommandWithWrongInputsNumber()
{
$questions = array('What\'s your name?', 'How are you?', 'Where do you come from?');
$command = new Command('foo');
$command->setHelperSet(new HelperSet(array(new QuestionHelper())));
$command->setCode(function ($input, $output) use($questions, $command) {
$helper = $command->getHelper('question');
$helper->ask($input, $output, new Question($questions[0]));
$helper->ask($input, $output, new Question($questions[1]));
$helper->ask($input, $output, new Question($questions[2]));
});
$tester = new CommandTester($command);
$tester->setInputs(array('Bobby', 'Fine'));
$tester->execute(array());
}
示例6: getDestinationHelper
/**
* @return DestinationHelper
*/
private function getDestinationHelper() : DestinationHelper
{
return parent::getHelper('link.destination');
}
示例7: getHelper
public function getHelper($name)
{
return $this->innerCommand->getHelper($name);
}
示例8: getHelper
public function getHelper($name)
{
return parent::getHelper($name);
}
示例9: setExpectedCommandInput
/**
* @param Command $command
* @param array|string $input
*/
protected function setExpectedCommandInput(Command $command, $input)
{
if (is_array($input)) {
$input = implode("\n", $input);
}
$helper = $command->getHelper('gush_question');
$helper->setInputStream($this->getInputStream($input));
}
示例10: getHelper
/**
* {@inheritdoc}
*/
public function getHelper($name)
{
$helper = parent::getHelper($name);
if ($this->input !== null && $helper instanceof InputAwareInterface) {
$helper->setInput($this->input);
}
if ($this->output !== null && $helper instanceof OutputAwareInterface) {
$helper->setOutput($this->output);
}
return $helper;
}