mirror of
https://github.com/shlinkio/shlink.git
synced 2024-12-23 15:40:33 -06:00
Simplified UrlShortenerConfigCustomizerPlugin thanks to SymfonyStyle
This commit is contained in:
parent
b17f96043a
commit
0a681f0efa
@ -42,9 +42,7 @@ class DatabaseConfigCustomizerPlugin extends AbstractConfigCustomizerPlugin
|
|||||||
$io = new SymfonyStyle($input, $output);
|
$io = new SymfonyStyle($input, $output);
|
||||||
$io->title('DATABASE');
|
$io->title('DATABASE');
|
||||||
|
|
||||||
if ($appConfig->hasDatabase() && $io->confirm(
|
if ($appConfig->hasDatabase() && $io->confirm('Do you want to keep imported database config?')) {
|
||||||
'<question>Do you want to keep imported database config? (Y/n)</question> '
|
|
||||||
)) {
|
|
||||||
// If the user selected to keep DB config and is configured to use sqlite, copy DB file
|
// 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']) {
|
if ($appConfig->getDatabase()['DRIVER'] === self::DATABASE_DRIVERS['SQLite']) {
|
||||||
try {
|
try {
|
||||||
|
@ -24,29 +24,26 @@ class UrlShortenerConfigCustomizerPlugin extends AbstractConfigCustomizerPlugin
|
|||||||
$io = new SymfonyStyle($input, $output);
|
$io = new SymfonyStyle($input, $output);
|
||||||
$io->title('URL SHORTENER');
|
$io->title('URL SHORTENER');
|
||||||
|
|
||||||
if ($appConfig->hasUrlShortener() && $io->confirm(
|
if ($appConfig->hasUrlShortener() && $io->confirm('Do you want to keep imported URL shortener config?')) {
|
||||||
'<question>Do you want to keep imported URL shortener config? (Y/n):</question> '
|
|
||||||
)) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ask for URL shortener params
|
// Ask for URL shortener params
|
||||||
$appConfig->setUrlShortener([
|
$appConfig->setUrlShortener([
|
||||||
'SCHEMA' => $io->choice(
|
'SCHEMA' => $io->choice(
|
||||||
'<question>Select schema for generated short URLs (defaults to http):</question>',
|
'Select schema for generated short URLs',
|
||||||
['http', 'https'],
|
['http', 'https'],
|
||||||
0
|
'http'
|
||||||
),
|
),
|
||||||
'HOSTNAME' => $this->ask($io, 'Hostname for generated URLs'),
|
'HOSTNAME' => $io->ask('Hostname for generated URLs'),
|
||||||
'CHARS' => $this->ask(
|
'CHARS' => $io->ask(
|
||||||
$io,
|
|
||||||
'Character set for generated short codes (leave empty to autogenerate one)',
|
'Character set for generated short codes (leave empty to autogenerate one)',
|
||||||
null,
|
null,
|
||||||
true
|
function ($value) {
|
||||||
) ?: str_shuffle(UrlShortener::DEFAULT_CHARS),
|
return $value;
|
||||||
'VALIDATE_URL' => $io->confirm(
|
}
|
||||||
'<question>Do you want to validate long urls by 200 HTTP status code on response (Y/n):</question>'
|
) ?: \str_shuffle(UrlShortener::DEFAULT_CHARS),
|
||||||
),
|
'VALIDATE_URL' => $io->confirm('Do you want to validate long urls by 200 HTTP status code on response'),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user