Applied SymfonyStyle to all installation config customizers

This commit is contained in:
Alejandro Celaya 2017-12-31 17:07:39 +01:00
parent 0a681f0efa
commit d275316acd
4 changed files with 13 additions and 28 deletions

View file

@ -18,25 +18,23 @@ class ApplicationConfigCustomizerPlugin extends AbstractConfigCustomizerPlugin
* @param OutputInterface $output
* @param CustomizableAppConfig $appConfig
* @return void
* @throws \Symfony\Component\Console\Exception\RuntimeException
*/
public function process(InputInterface $input, OutputInterface $output, CustomizableAppConfig $appConfig)
{
$io = new SymfonyStyle($input, $output);
$io->title('APPLICATION');
if ($appConfig->hasApp() && $io->confirm(
'<question>Do you want to keep imported application config? (Y/n):</question> '
)) {
if ($appConfig->hasApp() && $io->confirm('Do you want to keep imported application config?')) {
return;
}
$appConfig->setApp([
'SECRET' => $this->ask(
$io,
'SECRET' => $io->ask(
'Define a secret string that will be used to sign API tokens (leave empty to autogenerate one)',
null,
true
function ($value) {
return $value;
}
) ?: $this->generateRandomString(32),
]);
}

View file

@ -4,7 +4,6 @@ declare(strict_types=1);
namespace Shlinkio\Shlink\CLI\Install\Plugin;
use Shlinkio\Shlink\CLI\Model\CustomizableAppConfig;
use Symfony\Component\Console\Exception\RuntimeException;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
@ -35,7 +34,6 @@ class DatabaseConfigCustomizerPlugin extends AbstractConfigCustomizerPlugin
* @param CustomizableAppConfig $appConfig
* @return void
* @throws IOException
* @throws RuntimeException
*/
public function process(InputInterface $input, OutputInterface $output, CustomizableAppConfig $appConfig)
{

View file

@ -4,7 +4,6 @@ declare(strict_types=1);
namespace Shlinkio\Shlink\CLI\Install\Plugin;
use Shlinkio\Shlink\CLI\Model\CustomizableAppConfig;
use Symfony\Component\Console\Exception\RuntimeException;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
@ -18,32 +17,24 @@ class LanguageConfigCustomizerPlugin extends AbstractConfigCustomizerPlugin
* @param OutputInterface $output
* @param CustomizableAppConfig $appConfig
* @return void
* @throws RuntimeException
*/
public function process(InputInterface $input, OutputInterface $output, CustomizableAppConfig $appConfig)
{
$io = new SymfonyStyle($input, $output);
$io->title('LANGUAGE');
if ($appConfig->hasLanguage() && $io->confirm(
'<question>Do you want to keep imported language? (Y/n):</question> '
)) {
if ($appConfig->hasLanguage() && $io->confirm('Do you want to keep imported language?')) {
return;
}
$appConfig->setLanguage([
'DEFAULT' => $io->choice(
'<question>Select default language for the application in general (defaults to '
. self::SUPPORTED_LANGUAGES[0] . '):</question>',
self::SUPPORTED_LANGUAGES,
0
),
'CLI' => $io->choice(
'<question>Select default language for CLI executions (defaults to '
. self::SUPPORTED_LANGUAGES[0] . '):</question>',
self::SUPPORTED_LANGUAGES,
0
),
'DEFAULT' => $this->chooseLanguage('Select default language for the application in general', $io),
'CLI' => $this->chooseLanguage('Select default language for CLI executions', $io),
]);
}
private function chooseLanguage(string $message, SymfonyStyle $io): string
{
return $io->choice($message, self::SUPPORTED_LANGUAGES, self::SUPPORTED_LANGUAGES[0]);
}
}

View file

@ -5,7 +5,6 @@ namespace Shlinkio\Shlink\CLI\Install\Plugin;
use Shlinkio\Shlink\CLI\Model\CustomizableAppConfig;
use Shlinkio\Shlink\Core\Service\UrlShortener;
use Symfony\Component\Console\Exception\RuntimeException;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
@ -17,7 +16,6 @@ class UrlShortenerConfigCustomizerPlugin extends AbstractConfigCustomizerPlugin
* @param OutputInterface $output
* @param CustomizableAppConfig $appConfig
* @return void
* @throws RuntimeException
*/
public function process(InputInterface $input, OutputInterface $output, CustomizableAppConfig $appConfig)
{