本文整理汇总了PHP中Symfony\Component\Console\Helper\DialogHelper::askConfirmation方法的典型用法代码示例。如果您正苦于以下问题:PHP DialogHelper::askConfirmation方法的具体用法?PHP DialogHelper::askConfirmation怎么用?PHP DialogHelper::askConfirmation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\Console\Helper\DialogHelper
的用法示例。
在下文中一共展示了DialogHelper::askConfirmation方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: configure
/**
* Asks user what the path to Php source is.
*/
public function configure()
{
$default = $this->settings->getDefaultValueFor('enablePhpTools', true);
$this->settings['enablePhpTools'] = $this->dialog->askConfirmation($this->output, "\nDo you want to install the QA tools for PHP?", $default);
if ($this->settings['enablePhpTools']) {
$this->output->writeln("\n<info>Configuring PHP inspections</info>\n");
}
}
示例2: configure
public function configure()
{
if (!$this->settings['enablePhpTools']) {
$this->settings['enableComposer'] = false;
return false;
}
$this->settings['enableComposer'] = $this->dialog->askConfirmation($this->output, "Do you want to run `./composer.phar install` on every commit?", $this->settings->getDefaultValueFor('enableComposer', false));
}
示例3: configure
/**
* Asks user if they want to configure Behat.
*/
public function configure()
{
$default = $this->settings->getDefaultValueFor('enableBehat', true);
$this->settings['enableBehat'] = $this->dialog->askConfirmation($this->output, "\nDo you want to install the Behat framework?", $default);
if ($this->settings['enableBehat']) {
$this->settings['featuresDir'] = $this->settings->getBaseDir() . '/features';
}
}
示例4: configure
public function configure()
{
if (!$this->settings['enablePhpTools']) {
$this->settings['enablePhpSecurityChecker'] = false;
return false;
}
$default = $this->settings->getDefaultValueFor('enablePhpSecurityChecker', true);
$this->settings['enablePhpSecurityChecker'] = $this->dialog->askConfirmation($this->output, "Do you want to enable the Sensiolabs Security Checker?", $default);
}
示例5: configure
/**
*
*/
public function configure()
{
if (!$this->settings['enablePhpTools']) {
$this->settings['enablePhpLint'] = false;
return false;
}
$default = $this->settings->getDefaultValueFor('enablePhpLint', true);
$this->settings['enablePhpLint'] = $this->dialog->askConfirmation($this->output, "Do you want to enable PHP Lint?", $default);
}
示例6: configure
public function configure()
{
if (!$this->settings['enablePhpTools']) {
$this->settings['enablePhpMessDetector'] = false;
return false;
}
$default = $this->settings->getDefaultValueFor('enablePhpMessDetector', true);
$this->settings['enablePhpMessDetector'] = $this->dialog->askConfirmation($this->output, "Do you want to enable the PHP Mess Detector?", $default);
// Exclude default patterns
$default = $this->settings->getDefaultValueFor('phpMdExcludePatterns', array());
$excludePatterns = $this->multiplePathHelper->askPatterns(" - Which patterns should be excluded for PHP Mess Detector?", implode(',', $default), " - Do you want to exclude custom patterns for PHP Mess Detector?", !empty($default));
$this->settings['phpMdExcludePatterns'] = $excludePatterns;
}
示例7: testAskConfirmation
public function testAskConfirmation()
{
$dialog = new DialogHelper();
$dialog->setInputStream($this->getInputStream("\n\n"));
$this->assertTrue($dialog->askConfirmation($this->getOutputStream(), 'Do you like French fries?'));
$this->assertFalse($dialog->askConfirmation($this->getOutputStream(), 'Do you like French fries?', false));
$dialog->setInputStream($this->getInputStream("y\nyes\n"));
$this->assertTrue($dialog->askConfirmation($this->getOutputStream(), 'Do you like French fries?', false));
$this->assertTrue($dialog->askConfirmation($this->getOutputStream(), 'Do you like French fries?', false));
$dialog->setInputStream($this->getInputStream("n\nno\n"));
$this->assertFalse($dialog->askConfirmation($this->getOutputStream(), 'Do you like French fries?', true));
$this->assertFalse($dialog->askConfirmation($this->getOutputStream(), 'Do you like French fries?', true));
}
示例8: configure
public function configure()
{
if (!$this->settings['enablePhpTools']) {
$this->settings['enablePhpCopyPasteDetection'] = false;
return;
}
$default = $this->settings->getDefaultValueFor('enablePhpCopyPasteDetection', false);
$this->settings['enablePhpCopyPasteDetection'] = $this->dialog->askConfirmation($this->output, "Do you want to enable PHP Copy Paste Detection?", $default);
if (!$this->settings['enablePhpCopyPasteDetection']) {
return;
}
// Tests is the Symfony default
$default = $this->settings->getDefaultValueFor('phpCpdExcludePatterns', 'Tests');
$this->settings['phpCpdExcludePatterns'] = $this->multiplePathHelper->askPatterns(" - Which patterns should be excluded for PHP Copy Paste detection?", $default, " - Do you want to exclude patterns for PHP Copy Paste detection?");
}
示例9: configure
public function configure()
{
if (!$this->settings['enableJsTools']) {
$this->settings['enableJsHint'] = false;
return;
}
$default = $this->settings->getDefaultValueFor('enableJsHint', true);
$this->settings['enableJsHint'] = $this->dialog->askConfirmation($this->output, "Do you want to enable JSHint?", $default);
if ($this->settings['enableJsHint'] === false) {
return;
}
$statusCode = $this->installJsHintCommand->run($this->input, $this->output);
if ($statusCode) {
$this->settings['enableJsHint'] = false;
}
}
示例10: execute
public function execute(InputInterface $input, OutputInterface $output)
{
# get the di container
$project = $this->getApplication()->getProject();
# verify if a output file name been passed
if (($out_file_name = $input->getArgument('out')) === null) {
$out_file_name = 'schema.xml';
} else {
$out_file_name = rtrim($out_file_name, '.xml') . '.xml';
}
# load the schema analyser
$schema_analyser = $project->getSchemaAnalyser();
#run the analyser
$schema = $schema_analyser->analyse($project->getDatabase(), $project->getXMLEngineBuilder());
# write the scheam file to the project folder (sources)
$sources_io = $project->getSourceIO();
$formatted_xml = $schema_analyser->format($schema->toXml());
try {
#Write config file to the project
$sources_io->write($out_file_name, '', $formatted_xml, $overrite = false);
$output->writeLn('<comment>++</comment> <info>sources/' . $out_file_name . '</info>');
} catch (FileExistException $e) {
#ask if they want to overrite
$dialog = new DialogHelper();
$answer = $dialog->askConfirmation($output, "<question>{$out_file_name} already exists do you want to Overrite? [y|n]</question>:", false);
if ($answer) {
#Write config file to the project
$sources_io->write($out_file_name, '', $formatted_xml, $overrite = true);
$output->writeLn('<comment>++</comment> <info>sources/' . $out_file_name . '</info>');
}
}
}
示例11: execute
public function execute(InputInterface $input, OutputInterface $output)
{
$dialog = new DialogHelper();
if (!$input->getOption('silent')) {
$confirmed = $dialog->askConfirmation($output, "This will install all TestGuy dependencies through PEAR installer.\n" . "PHPUnit, Symfony Components, and Mink will be installed.\n" . "Make shure this script has permission to install PEAR packages.\n" . "Do you want to proceed? (Y/n)");
if (!$confirmed) {
return;
}
}
$output->writeln('Intalling PHPUnit...');
$output->write(shell_exec('pear config-set auto_discover 1'));
$output->write(shell_exec('pear install --alldeps pear.phpunit.de/PHPUnit'));
$output->writeln("Installing Symfony Components...");
$output->write(shell_exec("pear channel-discover pear.symfony.com"));
$output->write(shell_exec('pear install symfony2/Finder'));
$output->write(shell_exec('pear install symfony2/Process'));
$output->write(shell_exec('pear install symfony2/CssSelector'));
$output->write(shell_exec('pear install symfony2/DomCrawler'));
$output->write(shell_exec('pear install symfony2/BrowserKit'));
$output->writeln("Installing Mink...");
$output->write(shell_exec("pear channel-discover pear.behat.org"));
$output->write(shell_exec("pear install behat/mink"));
$output->writeln('Please check PHPUnit was installed sucessfully. Run the "phpunit" command. If it is not avaible try installing PHPUnit manually');
$output->writeln("Installaction complete. Init your new TestGuy suite calling the 'init' command");
}
示例12: populateDatabase
private function populateDatabase(OutputInterface $output)
{
// Check if database exist
$stmt = $this->dbConnection->prepare('SHOW DATABASES LIKE ?');
$stmt->bindValue(1, $this->dbName);
$stmt->execute();
if ($stmt->rowCount() > 0) {
$output->writeln('<info>Waring, Database "' . $this->dbName . '" already exist!</info>');
$confirmation = $this->dialog->askConfirmation($output, '<question>Do you want to drop it? [N]</question> ', false);
// if user don't want to use it, reselect the database
if ($confirmation === false) {
$output->writeln('Okay, then please reselect database name');
$this->selectDatabase($output);
$this->populateDatabase($output);
return;
} else {
// Delete database
$output->writeln('<info>Delete database....</info>');
$this->dbConnection->executeQuery('DROP DATABASE ' . $this->dbName);
}
}
$output->writeln('<info>Create database "' . $this->dbName . '"...</info>');
$this->dbConnection->executeQuery('CREATE DATABASE ' . $this->dbName . ' COLLATE utf8_general_ci');
$output->writeln('<info>Select database "' . $this->dbName . '"...</info>');
$this->dbConnection->executeQuery('USE ' . $this->dbName);
$output->writeln('<info>Populating table....</info>');
$this->dbConnection->executeQuery($this->tableQuery);
$output->writeln('<info>Populating table SUCCESS!</info>');
}
示例13: processTask
/**
* @param string $task
* @param CompareService $service
* @param OutputInterface $output
* @param array $dbs
* @param bool $loaded
* @return array
*/
protected function processTask($task, CompareService $service, OutputInterface $output, array $dbs, $loaded)
{
$queries = [];
switch ($task) {
case 'create':
if ($this->interactive >= self::INTERACTION_LOW) {
$renames = $this->dialog->askConfirmation($output, '<question>Attempt to rename tables? - Default true if interactive + loaded dependencies, false in other cases</question>', $this->interactive && $loaded);
} else {
$renames = false;
}
if ($renames && !$loaded) {
//inform the user, but let them shoot themselves in the foot regardless...
$output->writeln('<error>Renaming tables without checking relations between tables is dangerous!</error>');
}
$return = $service->getMissingTablesFor($dbs['base'], $dbs['target'], $renames);
$output->writeln(sprintf('<info>Added %d new tables (%s)</info>', count($return['added']), implode(', ', array_keys($return['added']))));
/** @var Table $table */
foreach ($return['added'] as $table) {
$queries[] = $table->getDefinitionString();
}
if ($return['renames']) {
$process = $this->processRenames($return['renames'], $output);
/** @var Database $base */
$base = $dbs['base'];
$base->addMissingTables($process['add']);
foreach ($process['add'] as $table) {
$queries[] = $table->getDefinitionString();
}
foreach ($process['rename'] as $oldName => $table) {
$queries[] = $table->getRenameQuery();
$base->applyRename($table, $oldName);
}
}
break;
case 'alter':
$dropFields = false;
$checkFks = false;
if ($this->interactive) {
$dropFields = $this->dialog->askConfirmation($output, '<question>Drop fields not in target table? (default: false)</question>', $dropFields);
$checkFks = $this->dialog->askConfirmation($output, '<question>Check Foreign Key constraints? (default: false)</question>', $checkFks);
}
$queries = $service->compareTables($dbs['base'], $dbs['target'], $dropFields, $checkFks);
break;
case 'constraints':
$output->writeln('<info>constraints task not implemented yet</info>');
$queries[] = '';
break;
case 'drop':
if (!$loaded) {
$output->writeln('<error>Cannot reliably drop tables if relational table links were not set up</error>');
$output->writeln('<comment>As a result, these drop statements might not work</comment>');
}
$queries = $service->dropRedundantTables($dbs['base'], $dbs['target']);
break;
default:
$queries[] = '';
}
return $queries;
}
示例14: shouldRemove
/**
* @return bool
*/
protected function shouldRemove()
{
$shouldRemove = $this->input->getOption('force');
if (!$shouldRemove) {
$shouldRemove = $this->dialog->askConfirmation($this->output, $this->getQuestion('Are you sure?', 'n'), false);
}
return $shouldRemove;
}
示例15: askConfirmation
/**
* @param string $question
* @param bool $default
*
* @return Boolean
*/
public function askConfirmation($question, $default = true)
{
$lines = array();
$lines[] = '<question>' . str_repeat(' ', 70) . "</question>";
foreach (explode("\n", wordwrap($question), 50) as $line) {
$lines[] = '<question> ' . str_pad($line, 68) . '</question>';
}
$lines[] = '<question>' . str_repeat(' ', 62) . '</question> <value>' . ($default ? '[Y/n]' : '[y/N]') . '</value> ';
return $this->dialogHelper->askConfirmation($this->output, implode("\n", $lines), $default);
}