Ensured required config options cannot be left empty

This commit is contained in:
Alejandro Celaya
2018-09-30 09:40:43 +02:00
parent 48f01921e1
commit 8323b87076
8 changed files with 83 additions and 22 deletions

View File

@@ -5,11 +5,14 @@ namespace Shlinkio\Shlink\Installer\Config\Plugin;
use Shlinkio\Shlink\Core\Service\UrlShortener;
use Shlinkio\Shlink\Installer\Model\CustomizableAppConfig;
use Shlinkio\Shlink\Installer\Util\AskUtilsTrait;
use Symfony\Component\Console\Style\SymfonyStyle;
use function str_shuffle;
class UrlShortenerConfigCustomizer implements ConfigCustomizerInterface
{
use AskUtilsTrait;
public function process(SymfonyStyle $io, CustomizableAppConfig $appConfig): void
{
$io->title('URL SHORTENER');
@@ -25,14 +28,9 @@ class UrlShortenerConfigCustomizer implements ConfigCustomizerInterface
['http', 'https'],
'http'
),
'HOSTNAME' => $io->ask('Hostname for generated URLs'),
'CHARS' => $io->ask(
'Character set for generated short codes (leave empty to autogenerate one)',
null,
function ($value) {
return $value;
}
) ?: str_shuffle(UrlShortener::DEFAULT_CHARS),
'HOSTNAME' => $this->askRequired($io, 'hostname', 'Hostname for generated URLs'),
'CHARS' => $io->ask('Character set for generated short codes (leave empty to autogenerate one)')
?: str_shuffle(UrlShortener::DEFAULT_CHARS),
'VALIDATE_URL' => $io->confirm('Do you want to validate long urls by 200 HTTP status code on response'),
]);
}