diff options
author | Joas Schilling <coding@schilljs.com> | 2016-09-07 09:23:47 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-09-07 09:23:47 +0200 |
commit | 0027304b5fc0a92106dca948b72b6fad04b91299 (patch) | |
tree | fb386fc597d4d4c05b885a4ce283db74a71330fd /core | |
parent | 74daac49ac4ddfc95b2c90f2784964bf4b8eb2b3 (diff) | |
parent | 59e5ebf330777f39ea9f1e9a12b3a50af1859ed6 (diff) | |
download | nextcloud-server-0027304b5fc0a92106dca948b72b6fad04b91299.tar.gz nextcloud-server-0027304b5fc0a92106dca948b72b6fad04b91299.zip |
Merge pull request #1210 from nextcloud/bump_symfony_console
[3rparty] Bump symfony/console
Diffstat (limited to 'core')
-rw-r--r-- | core/Command/Db/ConvertType.php | 37 | ||||
-rw-r--r-- | core/Command/Maintenance/Install.php | 28 | ||||
-rw-r--r-- | core/Command/User/Add.php | 23 | ||||
-rw-r--r-- | core/Command/User/Report.php | 6 | ||||
-rw-r--r-- | core/Command/User/ResetPassword.php | 28 |
5 files changed, 61 insertions, 61 deletions
diff --git a/core/Command/Db/ConvertType.php b/core/Command/Db/ConvertType.php index ccf5c0685cb..f8367f75867 100644 --- a/core/Command/Db/ConvertType.php +++ b/core/Command/Db/ConvertType.php @@ -32,10 +32,14 @@ use \OCP\IConfig; use OC\DB\Connection; use OC\DB\ConnectionFactory; use Symfony\Component\Console\Command\Command; +use Symfony\Component\Console\Helper\ProgressBar; +use Symfony\Component\Console\Helper\QuestionHelper; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; +use Symfony\Component\Console\Question\ConfirmationQuestion; +use Symfony\Component\Console\Question\Question; class ConvertType extends Command { /** @@ -158,13 +162,12 @@ class ConvertType extends Command { // Read password by interacting if ($input->isInteractive()) { - /** @var $dialog \Symfony\Component\Console\Helper\DialogHelper */ - $dialog = $this->getHelperSet()->get('dialog'); - $password = $dialog->askHiddenResponse( - $output, - '<question>What is the database password?</question>', - false - ); + /** @var QuestionHelper $helper */ + $helper = $this->getHelper('question'); + $question = new Question('What is the database password?'); + $question->setHidden(true); + $question->setHiddenFallback(false); + $password = $helper->ask($input, $output, $question); $input->setOption('password', $password); return; } @@ -195,13 +198,12 @@ class ConvertType extends Command { $output->writeln('<comment>Please note that tables belonging to available but currently not installed apps</comment>'); $output->writeln('<comment>can be included by specifying the --all-apps option.</comment>'); } - /** @var $dialog \Symfony\Component\Console\Helper\DialogHelper */ - $dialog = $this->getHelperSet()->get('dialog'); - if (!$dialog->askConfirmation( - $output, - '<question>Continue with the conversion (y/n)? [n] </question>', - false - )) { + + /** @var QuestionHelper $helper */ + $helper = $this->getHelper('question'); + $question = new ConfirmationQuestion('Continue with the conversion (y/n)? [n] ', false); + + if (!$helper->ask($input, $output, $question)) { return; } } @@ -256,9 +258,6 @@ class ConvertType extends Command { protected function copyTable(Connection $fromDB, Connection $toDB, $table, InputInterface $input, OutputInterface $output) { $chunkSize = $input->getOption('chunk-size'); - /** @var $progress \Symfony\Component\Console\Helper\ProgressHelper */ - $progress = $this->getHelperSet()->get('progress'); - $query = $fromDB->getQueryBuilder(); $query->automaticTablePrefix(false); $query->selectAlias($query->createFunction('COUNT(*)'), 'num_entries') @@ -272,11 +271,11 @@ class ConvertType extends Command { $output->writeln('chunked query, ' . $numChunks . ' chunks'); } - $progress->start($output, $count); + $progress = new ProgressBar($output, $count); + $progress->start(); $redraw = $count > $chunkSize ? 100 : ($count > 100 ? 5 : 1); $progress->setRedrawFrequency($redraw); - $query = $fromDB->getQueryBuilder(); $query->automaticTablePrefix(false); $query->select('*') diff --git a/core/Command/Maintenance/Install.php b/core/Command/Maintenance/Install.php index 4e84becf770..4b76a1f608c 100644 --- a/core/Command/Maintenance/Install.php +++ b/core/Command/Maintenance/Install.php @@ -31,9 +31,11 @@ use InvalidArgumentException; use OC\Setup; use OCP\IConfig; use Symfony\Component\Console\Command\Command; +use Symfony\Component\Console\Helper\QuestionHelper; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; +use Symfony\Component\Console\Question\Question; class Install extends Command { @@ -138,24 +140,22 @@ class Install extends Command { throw new InvalidArgumentException("Database name not provided."); } if (is_null($dbPass)) { - /** @var $dialog \Symfony\Component\Console\Helper\DialogHelper */ - $dialog = $this->getHelperSet()->get('dialog'); - $dbPass = $dialog->askHiddenResponse( - $output, - "<question>What is the password to access the database with user <$dbUser>?</question>", - false - ); + /** @var QuestionHelper $helper */ + $helper = $this->getHelper('question'); + $question = new Question('What is the password to access the database with user <'.$dbUser.'>?'); + $question->setHidden(true); + $question->setHiddenFallback(false); + $dbPass = $helper->ask($input, $output, $question); } } if (is_null($adminPassword)) { - /** @var $dialog \Symfony\Component\Console\Helper\DialogHelper */ - $dialog = $this->getHelperSet()->get('dialog'); - $adminPassword = $dialog->askHiddenResponse( - $output, - "<question>What is the password you like to use for the admin account <$adminLogin>?</question>", - false - ); + /** @var QuestionHelper $helper */ + $helper = $this->getHelper('question'); + $question = new Question('What is the password you like to use for the admin account <'.$adminLogin.'>?'); + $question->setHidden(true); + $question->setHiddenFallback(false); + $adminPassword = $helper->ask($input, $output, $question); } $options = [ diff --git a/core/Command/User/Add.php b/core/Command/User/Add.php index a0ca3315154..368f06cba85 100644 --- a/core/Command/User/Add.php +++ b/core/Command/User/Add.php @@ -28,6 +28,7 @@ use OCP\IGroupManager; use OCP\IUser; use OCP\IUserManager; use Symfony\Component\Console\Command\Command; +use Symfony\Component\Console\Helper\QuestionHelper; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; @@ -94,18 +95,16 @@ class Add extends Command { return 1; } } elseif ($input->isInteractive()) { - /** @var $dialog \Symfony\Component\Console\Helper\DialogHelper */ - $dialog = $this->getHelperSet()->get('dialog'); - $password = $dialog->askHiddenResponse( - $output, - '<question>Enter password: </question>', - false - ); - $confirm = $dialog->askHiddenResponse( - $output, - '<question>Confirm password: </question>', - false - ); + /** @var QuestionHelper $helper */ + $helper = $this->getHelper('question'); + + $question = new Question('Enter password: '); + $question->setHidden(true); + $password = $helper->ask($input, $output, $question); + + $question = new Question('Confirm password: '); + $question->setHidden(true); + $confirm = $helper->ask($input, $output,$question); if ($password !== $confirm) { $output->writeln("<error>Passwords did not match!</error>"); diff --git a/core/Command/User/Report.php b/core/Command/User/Report.php index 01eb51f17f9..9a3bd9e5906 100644 --- a/core/Command/User/Report.php +++ b/core/Command/User/Report.php @@ -27,6 +27,7 @@ namespace OC\Core\Command\User; use OCP\IUserManager; use Symfony\Component\Console\Command\Command; +use Symfony\Component\Console\Helper\Table; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; @@ -49,8 +50,7 @@ class Report extends Command { } protected function execute(InputInterface $input, OutputInterface $output) { - /** @var \Symfony\Component\Console\Helper\TableHelper $table */ - $table = $this->getHelperSet()->get('table'); + $table = new Table($output); $table->setHeaders(array('User Report', '')); $userCountArray = $this->countUsers(); if(!empty($userCountArray)) { @@ -72,7 +72,7 @@ class Report extends Command { $rows[] = array('user directories', $userDirectoryCount); $table->setRows($rows); - $table->render($output); + $table->render(); } private function countUsers() { diff --git a/core/Command/User/ResetPassword.php b/core/Command/User/ResetPassword.php index ed8cf53b990..cf8c894d7a7 100644 --- a/core/Command/User/ResetPassword.php +++ b/core/Command/User/ResetPassword.php @@ -29,10 +29,13 @@ namespace OC\Core\Command\User; use OCP\IUserManager; use Symfony\Component\Console\Command\Command; +use Symfony\Component\Console\Helper\QuestionHelper; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; +use Symfony\Component\Console\Question\ConfirmationQuestion; +use Symfony\Component\Console\Question\Question; class ResetPassword extends Command { @@ -79,28 +82,27 @@ class ResetPassword extends Command { return 1; } } elseif ($input->isInteractive()) { - /** @var $dialog \Symfony\Component\Console\Helper\DialogHelper */ - $dialog = $this->getHelperSet()->get('dialog'); + /** @var QuestionHelper $helper */ + $helper = $this->getHelper('question'); if (\OCP\App::isEnabled('encryption')) { $output->writeln( '<error>Warning: Resetting the password when using encryption will result in data loss!</error>' ); - if (!$dialog->askConfirmation($output, '<question>Do you want to continue?</question>', true)) { + + $question = new ConfirmationQuestion('Do you want to continue?'); + if (!$helper->ask($input, $output, $question)) { return 1; } } - $password = $dialog->askHiddenResponse( - $output, - '<question>Enter a new password: </question>', - false - ); - $confirm = $dialog->askHiddenResponse( - $output, - '<question>Confirm the new password: </question>', - false - ); + $question = new Question('Enter a new password: '); + $question->setHidden(true); + $password = $helper->ask($input, $output, $question); + + $question = new Question('Conform the new password: '); + $question->setHidden(true); + $confirm = $helper->ask($input, $output, $question); if ($password !== $confirm) { $output->writeln("<error>Passwords did not match!</error>"); |