mirror of
https://github.com/shlinkio/shlink.git
synced 2025-02-25 18:45:27 -06:00
Added new visits_threshold config to installation
This commit is contained in:
parent
d68dc38959
commit
86c30ee731
@ -15,9 +15,13 @@ class ApplicationConfigCustomizer implements ConfigCustomizerInterface
|
|||||||
|
|
||||||
public const SECRET = 'SECRET';
|
public const SECRET = 'SECRET';
|
||||||
public const DISABLE_TRACK_PARAM = 'DISABLE_TRACK_PARAM';
|
public const DISABLE_TRACK_PARAM = 'DISABLE_TRACK_PARAM';
|
||||||
|
public const CHECK_VISITS_THRESHOLD = 'CHECK_VISITS_THRESHOLD';
|
||||||
|
public const VISITS_THRESHOLD = 'VISITS_THRESHOLD';
|
||||||
private const EXPECTED_KEYS = [
|
private const EXPECTED_KEYS = [
|
||||||
self::SECRET,
|
self::SECRET,
|
||||||
self::DISABLE_TRACK_PARAM,
|
self::DISABLE_TRACK_PARAM,
|
||||||
|
self::CHECK_VISITS_THRESHOLD,
|
||||||
|
self::VISITS_THRESHOLD,
|
||||||
];
|
];
|
||||||
|
|
||||||
public function process(SymfonyStyle $io, CustomizableAppConfig $appConfig): void
|
public function process(SymfonyStyle $io, CustomizableAppConfig $appConfig): void
|
||||||
@ -31,6 +35,11 @@ class ApplicationConfigCustomizer implements ConfigCustomizerInterface
|
|||||||
|
|
||||||
$io->title('APPLICATION');
|
$io->title('APPLICATION');
|
||||||
foreach ($keysToAskFor as $key) {
|
foreach ($keysToAskFor as $key) {
|
||||||
|
// Skip visits threshold when the user decided not to check visits on deletions
|
||||||
|
if ($key === self::VISITS_THRESHOLD && ! $app[self::CHECK_VISITS_THRESHOLD]) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
$app[$key] = $this->ask($io, $key);
|
$app[$key] = $this->ask($io, $key);
|
||||||
}
|
}
|
||||||
$appConfig->setApp($app);
|
$appConfig->setApp($app);
|
||||||
@ -49,6 +58,16 @@ class ApplicationConfigCustomizer implements ConfigCustomizerInterface
|
|||||||
'Provide a parameter name that you will be able to use to disable tracking on specific request to '
|
'Provide a parameter name that you will be able to use to disable tracking on specific request to '
|
||||||
. 'short URLs (leave empty and this feature won\'t be enabled)'
|
. 'short URLs (leave empty and this feature won\'t be enabled)'
|
||||||
);
|
);
|
||||||
|
case self::CHECK_VISITS_THRESHOLD:
|
||||||
|
return $io->confirm(
|
||||||
|
'Do you want to enable a safety check which will not allow short URLs to be deleted when they '
|
||||||
|
. 'have more than a specific amount of visits?'
|
||||||
|
);
|
||||||
|
case self::VISITS_THRESHOLD:
|
||||||
|
return $io->ask(
|
||||||
|
'What is the amount of visits from which the system will not allow short URLs to be deleted?',
|
||||||
|
15
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return '';
|
return '';
|
||||||
|
@ -121,6 +121,8 @@ final class CustomizableAppConfig implements ArraySerializableInterface
|
|||||||
$this->setApp($this->mapExistingPathsToKeys([
|
$this->setApp($this->mapExistingPathsToKeys([
|
||||||
ApplicationConfigCustomizer::SECRET => ['app_options', 'secret_key'],
|
ApplicationConfigCustomizer::SECRET => ['app_options', 'secret_key'],
|
||||||
ApplicationConfigCustomizer::DISABLE_TRACK_PARAM => ['app_options', 'disable_track_param'],
|
ApplicationConfigCustomizer::DISABLE_TRACK_PARAM => ['app_options', 'disable_track_param'],
|
||||||
|
ApplicationConfigCustomizer::CHECK_VISITS_THRESHOLD => ['delete_short_urls', 'check_visits_threshold'],
|
||||||
|
ApplicationConfigCustomizer::VISITS_THRESHOLD => ['delete_short_urls', 'visits_threshold'],
|
||||||
], $array));
|
], $array));
|
||||||
|
|
||||||
$this->setDatabase($this->mapExistingPathsToKeys([
|
$this->setDatabase($this->mapExistingPathsToKeys([
|
||||||
@ -165,6 +167,10 @@ final class CustomizableAppConfig implements ArraySerializableInterface
|
|||||||
'secret_key' => $this->app[ApplicationConfigCustomizer::SECRET] ?? '',
|
'secret_key' => $this->app[ApplicationConfigCustomizer::SECRET] ?? '',
|
||||||
'disable_track_param' => $this->app[ApplicationConfigCustomizer::DISABLE_TRACK_PARAM] ?? null,
|
'disable_track_param' => $this->app[ApplicationConfigCustomizer::DISABLE_TRACK_PARAM] ?? null,
|
||||||
],
|
],
|
||||||
|
'delete_short_urls' => [
|
||||||
|
'check_visits_threshold' => $this->app[ApplicationConfigCustomizer::CHECK_VISITS_THRESHOLD] ?? true,
|
||||||
|
'visits_threshold' => $this->app[ApplicationConfigCustomizer::VISITS_THRESHOLD] ?? 15,
|
||||||
|
],
|
||||||
'entity_manager' => [
|
'entity_manager' => [
|
||||||
'connection' => [
|
'connection' => [
|
||||||
'driver' => $dbDriver,
|
'driver' => $dbDriver,
|
||||||
|
Loading…
Reference in New Issue
Block a user