本文整理汇总了PHP中Symfony\Component\Console\Style\SymfonyStyle::choice方法的典型用法代码示例。如果您正苦于以下问题:PHP SymfonyStyle::choice方法的具体用法?PHP SymfonyStyle::choice怎么用?PHP SymfonyStyle::choice使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\Console\Style\SymfonyStyle
的用法示例。
在下文中一共展示了SymfonyStyle::choice方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getStop
private function getStop($value, $question = 'Which station ?')
{
$stops = $this->cff->getStop($value, false);
if ($stops[0]['value'] != $value) {
$values = array_column($stops, 'value');
$value = $this->io->choice($question, $values, $stops[0]['value']);
$key = array_search($value, $values);
return $stops[$key];
}
return $stops[0];
}
示例2: selectBundle
/**
* @param Bundle[] $bundles
*
* @return Bundle|null
*/
private function selectBundle(array $bundles)
{
$packageNames = array_map(function (Bundle $bundle) {
return $bundle->getName();
}, $bundles);
$selectedName = $this->io->choice('Please select the package, where you want to place the Migration file', $packageNames, $this->getContainer()->getParameter('campaignchain_update.diff_package'));
$this->io->text('You have selected: ' . $selectedName);
$selectedBundle = null;
foreach ($bundles as $bundle) {
if ($bundle->getName() != $selectedName) {
continue;
}
$selectedBundle = $bundle;
break;
}
return $selectedBundle;
}
示例3: execute
/**
* @inheritDoc
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$helper = new SymfonyStyle($input, $output);
$helper->title('Doctrine');
$choices = [self::ACTION_DATABASE_IMPORT => 'Import database from remote host'];
$todo = $helper->choice('Select action', $choices);
$helper->newLine(4);
$helper->section($choices[$todo]);
$this->executeChoice($helper, $todo);
CommandUtility::writeFinishedMessage($helper, self::NAME);
}
示例4: execute
/**
* @inheritDoc
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$helper = new SymfonyStyle($input, $output);
$helper->title('FOSUserBundle');
$choices = [self::ACTION_PASSWORD_REPLACE => 'Replace all passwords (be careful!)'];
$todo = $helper->choice('Select action', $choices);
$helper->newLine(4);
$helper->section($choices[$todo]);
$this->executeChoice($helper, $todo);
CommandUtility::writeFinishedMessage($helper, self::NAME);
}
示例5: interact
/**
* {@inheritdoc}
*/
protected function interact(InputInterface $input, OutputInterface $output)
{
$io = new SymfonyStyle($input, $output);
// --title option
if (!$input->getOption('title')) {
$input->setOption('title', $io->ask('Enter the title of the page'));
}
// --extension option
if (!$input->getOption('extension')) {
$input->setOption('extension', $io->choice('Which file extension?', ['md', 'html.twig', 'twig', 'html']));
}
// --fieldname option
if (!$input->getOption('filename')) {
$input->setOption('filename', $io->ask('Enter the name of the file', str_replace(' ', self::FILENAME_SEPARATOR, strtolower($input->getOption('title'))) . '.' . $input->getOption('extension')));
}
}
示例6: findProperServiceName
private function findProperServiceName(InputInterface $input, SymfonyStyle $io, ContainerBuilder $builder, $name)
{
if ($builder->has($name) || !$input->isInteractive()) {
return $name;
}
$matchingServices = $this->findServiceIdsContaining($builder, $name);
if (empty($matchingServices)) {
throw new \InvalidArgumentException(sprintf('No services found that match "%s".', $name));
}
$default = 1 === count($matchingServices) ? $matchingServices[0] : null;
return $io->choice('Select one of the following services to display its information', $matchingServices, $default);
}
示例7: selectWorkingLocale
private function selectWorkingLocale()
{
$this->workingLocale = $this->formatter->choice('What locale would you like to configure', $this->getInstallableLocale());
}
示例8: function
<?php
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
//Ensure questions do not output anything when input is non-interactive
return function (InputInterface $input, OutputInterface $output) {
$output = new SymfonyStyle($input, $output);
$output->title('Title');
$output->askHidden('Hidden question');
$output->choice('Choice question with default', array('choice1', 'choice2'), 'choice1');
$output->confirm('Confirmation with yes default', true);
$output->text('Duis aute irure dolor in reprehenderit in voluptate velit esse');
};