Skip to content

Commit 366ce7c

Browse files
committed
Fixed confirmation questions
1 parent 8af797e commit 366ce7c

8 files changed

+17
-22
lines changed

Diff for: src/PHPCR/Shell/Config/ConfigManager.php

+4-13
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ public function getPhpcrshConfig()
174174
/**
175175
* Initialize a configuration files.
176176
*/
177-
public function initConfig(OutputInterface $output = null, $noInteraction = false)
177+
public function initConfig(OutputInterface $output = null)
178178
{
179179
$log = function ($message) use ($output) {
180180
if ($output) {
@@ -208,18 +208,9 @@ public function initConfig(OutputInterface $output = null, $noInteraction = fals
208208
}
209209

210210
if ($this->filesystem->exists($destFile)) {
211-
if (false === $noInteraction) {
212-
$confirmed = $this->questionHelper->askConfirmation(
213-
$output,
214-
'"'.$configFilename.'" already exists, do you want to overwrite it?'
215-
);
216-
217-
if (!$confirmed) {
218-
continue;
219-
}
220-
} else {
221-
$log(sprintf('<info>File</info> %s <info> already exists, not overwriting.', $destFile));
222-
}
211+
$log(sprintf('<info>File</info> %s <info> already exists, not overwriting.', $destFile));
212+
213+
return;
223214
}
224215

225216
$this->filesystem->copy($srcFile, $destFile);

Diff for: src/PHPCR/Shell/Console/Command/Phpcr/NodeEditCommand.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
use Symfony\Component\Console\Input\InputInterface;
2121
use Symfony\Component\Console\Input\InputOption;
2222
use Symfony\Component\Console\Output\OutputInterface;
23+
use Symfony\Component\Console\Question\ConfirmationQuestion;
2324
use Symfony\Component\Serializer\Serializer;
2425

2526
class NodeEditCommand extends BasePhpcrCommand
@@ -121,7 +122,7 @@ public function execute(InputInterface $input, OutputInterface $output)
121122
$error = $e->getMessage();
122123
$output->writeln('<error>'.$error.'</error>');
123124
if (false === $input->getOption('no-interaction')) {
124-
$tryAgain = $dialog->askConfirmation($output, 'Do you want to try again? (y/n)');
125+
$tryAgain = $dialog->ask($input, $output, new ConfirmationQuestion('Do you want to try again? (y/n)'));
125126
}
126127
$outStr = $inStr;
127128
}

Diff for: src/PHPCR/Shell/Console/Command/Phpcr/NodePropertySetCommand.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public function execute(InputInterface $input, OutputInterface $output)
6565
if ($type) {
6666
$intType = PropertyType::valueFromName($type);
6767

68-
if ($intType === PropertyType::REFERENCE || $intType === PropertyType::WEAKREFERENCE) {
68+
if ($intType === PropertyType::REFERENCE || $intType === PropertyType::WEAKREFERENCE) {
6969
// convert path to UUID
7070
if (false === UUIDHelper::isUuid($value)) {
7171
$path = $value;

Diff for: src/PHPCR/Shell/Console/Command/Phpcr/NodeTypeEditCommand.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
use Symfony\Component\Console\Input\InputArgument;
2020
use Symfony\Component\Console\Input\InputInterface;
2121
use Symfony\Component\Console\Output\OutputInterface;
22+
use Symfony\Component\Console\Question\ConfirmationQuestion;
2223

2324
class NodeTypeEditCommand extends BasePhpcrCommand
2425
{
@@ -101,7 +102,7 @@ public function execute(InputInterface $input, OutputInterface $output)
101102

102103
$tryAgain = false;
103104
if (false === $input->getOption('no-interaction')) {
104-
$tryAgain = $dialog->askConfirmation($output, 'Do you want to try again? (y/n)');
105+
$tryAgain = $dialog->ask($input, $output, new ConfirmationQuestion('Do you want to try again? (y/n)'));
105106
}
106107

107108
if (false === $tryAgain) {

Diff for: src/PHPCR/Shell/Console/Command/Phpcr/SessionExportCommand.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
use Symfony\Component\Console\Input\InputInterface;
1818
use Symfony\Component\Console\Input\InputOption;
1919
use Symfony\Component\Console\Output\OutputInterface;
20+
use Symfony\Component\Console\Question\ConfirmationQuestion;
2021

2122
class SessionExportCommand extends BasePhpcrCommand
2223
{
@@ -64,7 +65,7 @@ public function execute(InputInterface $input, OutputInterface $output)
6465
$confirmed = true;
6566

6667
if (false === $input->getOption('no-interaction')) {
67-
$confirmed = $dialog->askConfirmation($output, 'File already exists, overwrite?');
68+
$confirmed = $dialog->ask($input, $output, new ConfirmationQuestion('File already exists, overwrite?'));
6869
}
6970

7071
if (false === $confirmed) {

Diff for: src/PHPCR/Shell/Console/Command/Shell/ConfigInitCommand.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,6 @@ public function execute(InputInterface $input, OutputInterface $output)
3434
{
3535
$this->output = $output;
3636
$configHelper = $this->get('config.manager');
37-
$configHelper->initConfig($output, $input->getOption('no-interaction'));
37+
$configHelper->initConfig($output);
3838
}
3939
}

Diff for: src/PHPCR/Shell/Console/Command/Shell/ExitCommand.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use PHPCR\Shell\Console\Command\BaseCommand;
1616
use Symfony\Component\Console\Input\InputInterface;
1717
use Symfony\Component\Console\Output\OutputInterface;
18+
use Symfony\Component\Console\Question\ConfirmationQuestion;
1819

1920
class ExitCommand extends BaseCommand
2021
{
@@ -28,13 +29,12 @@ public function execute(InputInterface $input, OutputInterface $output)
2829
{
2930
$dialog = $this->get('helper.question');
3031
$session = $this->get('phpcr.session');
31-
$noInteraction = $input->getOption('no-interaction');
3232

3333
if ($session->hasPendingChanges()) {
3434
$res = false;
3535

3636
if ($input->isInteractive()) {
37-
$res = $dialog->askConfirmation($output, '<question>Session has pending changes, are you sure you want to quit? (Y/N)</question>', false);
37+
$res = $dialog->ask($input, $output, new ConfirmationQuestion('<question>Session has pending changes, are you sure you want to quit? (Y/N)</question>', false));
3838
}
3939

4040
if (false === $res) {

Diff for: src/PHPCR/Shell/Subscriber/ProfileWriterSubscriber.php

+3-2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use PHPCR\Shell\Event\PhpcrShellEvents;
1717
use PHPCR\Shell\Event\ProfileInitEvent;
1818
use Symfony\Component\Console\Helper\QuestionHelper;
19+
use Symfony\Component\Console\Question\ConfirmationQuestion;
1920
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
2021

2122
class ProfileWriterSubscriber implements EventSubscriberInterface
@@ -54,14 +55,14 @@ public function handleProfileInit(ProfileInitEvent $e)
5455
if (file_exists($this->profileLoader->getProfilePath($profileName))) {
5556
$res = true;
5657
if (false === $noInteraction) {
57-
$res = $this->questionHelper->askConfirmation($output, sprintf('Update existing profile "%s"?', $profileName));
58+
$res = $this->questionHelper->ask($input, $output, new ConfirmationQuestion(sprintf('Update existing profile "%s"?', $profileName)));
5859
}
5960
$overwrite = true;
6061
} else {
6162
$res = true;
6263

6364
if (false === $noInteraction) {
64-
$res = $this->questionHelper->askConfirmation($output, sprintf('Create new profile "%s"?', $profileName));
65+
$res = $this->questionHelper->ask($input, $output, new ConfirmationQuestion(sprintf('Create new profile "%s"?', $profileName)));
6566
}
6667
}
6768

0 commit comments

Comments
 (0)