From 0a681f0efa68472205cdc4a15289ebd07978360e Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Sun, 31 Dec 2017 17:00:26 +0100 Subject: [PATCH] Simplified UrlShortenerConfigCustomizerPlugin thanks to SymfonyStyle --- .../Plugin/DatabaseConfigCustomizerPlugin.php | 4 +--- .../UrlShortenerConfigCustomizerPlugin.php | 23 ++++++++----------- 2 files changed, 11 insertions(+), 16 deletions(-) diff --git a/module/CLI/src/Install/Plugin/DatabaseConfigCustomizerPlugin.php b/module/CLI/src/Install/Plugin/DatabaseConfigCustomizerPlugin.php index bd1edda8..66144ccd 100644 --- a/module/CLI/src/Install/Plugin/DatabaseConfigCustomizerPlugin.php +++ b/module/CLI/src/Install/Plugin/DatabaseConfigCustomizerPlugin.php @@ -42,9 +42,7 @@ class DatabaseConfigCustomizerPlugin extends AbstractConfigCustomizerPlugin $io = new SymfonyStyle($input, $output); $io->title('DATABASE'); - if ($appConfig->hasDatabase() && $io->confirm( - 'Do you want to keep imported database config? (Y/n) ' - )) { + if ($appConfig->hasDatabase() && $io->confirm('Do you want to keep imported database config?')) { // If the user selected to keep DB config and is configured to use sqlite, copy DB file if ($appConfig->getDatabase()['DRIVER'] === self::DATABASE_DRIVERS['SQLite']) { try { diff --git a/module/CLI/src/Install/Plugin/UrlShortenerConfigCustomizerPlugin.php b/module/CLI/src/Install/Plugin/UrlShortenerConfigCustomizerPlugin.php index 77ad6653..f457bfa8 100644 --- a/module/CLI/src/Install/Plugin/UrlShortenerConfigCustomizerPlugin.php +++ b/module/CLI/src/Install/Plugin/UrlShortenerConfigCustomizerPlugin.php @@ -24,29 +24,26 @@ class UrlShortenerConfigCustomizerPlugin extends AbstractConfigCustomizerPlugin $io = new SymfonyStyle($input, $output); $io->title('URL SHORTENER'); - if ($appConfig->hasUrlShortener() && $io->confirm( - 'Do you want to keep imported URL shortener config? (Y/n): ' - )) { + if ($appConfig->hasUrlShortener() && $io->confirm('Do you want to keep imported URL shortener config?')) { return; } // Ask for URL shortener params $appConfig->setUrlShortener([ 'SCHEMA' => $io->choice( - 'Select schema for generated short URLs (defaults to http):', + 'Select schema for generated short URLs', ['http', 'https'], - 0 + 'http' ), - 'HOSTNAME' => $this->ask($io, 'Hostname for generated URLs'), - 'CHARS' => $this->ask( - $io, + 'HOSTNAME' => $io->ask('Hostname for generated URLs'), + 'CHARS' => $io->ask( 'Character set for generated short codes (leave empty to autogenerate one)', null, - true - ) ?: str_shuffle(UrlShortener::DEFAULT_CHARS), - 'VALIDATE_URL' => $io->confirm( - 'Do you want to validate long urls by 200 HTTP status code on response (Y/n):' - ), + function ($value) { + return $value; + } + ) ?: \str_shuffle(UrlShortener::DEFAULT_CHARS), + 'VALIDATE_URL' => $io->confirm('Do you want to validate long urls by 200 HTTP status code on response'), ]); } }