Issue #3437319 by srishtiiee, narendraR, pradhumanjain2311, phenaproxima, Wim Leers: Add validation constraints to update.settings

(cherry picked from commit d7bcfdf6d7)
merge-requests/7853/head
Alex Pott 2024-04-30 00:49:33 +01:00
parent af5acaaccb
commit 3ade5afd02
No known key found for this signature in database
GPG Key ID: BDA67E7EE836E5CE
3 changed files with 27 additions and 3 deletions

View File

@ -3,6 +3,8 @@
update.settings:
type: config_object
label: 'Update settings'
constraints:
FullyValidatable: ~
mapping:
check:
type: mapping
@ -14,6 +16,10 @@ update.settings:
interval_days:
type: integer
label: 'Days since last check'
constraints:
# @see \Drupal\update\UpdateSettingsForm::buildForm()
# The options are daily and weekly.
Choice: [1, 7]
fetch:
type: mapping
label: 'Fetch settings'
@ -25,9 +31,15 @@ update.settings:
max_attempts:
type: integer
label: 'Maximum attempts'
constraints:
Range:
min: 1
timeout:
type: integer
label: 'Timeout in seconds'
constraints:
Range:
min: 1
notification:
type: mapping
label: 'Notification settings'
@ -41,3 +53,6 @@ update.settings:
threshold:
type: string
label: 'Email notification threshold'
constraints:
# @see \Drupal\update\UpdateSettingsForm::buildForm()
Choice: [all, security]

View File

@ -19,6 +19,12 @@ process:
'notification/threshold': update_notification_threshold
'notification/emails': update_notify_emails
'check/interval_days': update_check_frequency
'check/disabled_extensions':
plugin: default_value
default_value: false
'fetch/timeout':
plugin: default_value
default_value: 30
destination:
plugin: config
config_name: update.settings

View File

@ -36,10 +36,13 @@ class UpdateSettingsForm extends ConfigFormBase {
$form['update_check_frequency'] = [
'#type' => 'radios',
'#title' => $this->t('Check for updates'),
'#config_target' => 'update.settings:check.interval_days',
'#config_target' => new ConfigTarget(
'update.settings',
'check.interval_days',
toConfig: fn($value) => intval($value)),
'#options' => [
'1' => $this->t('Daily'),
'7' => $this->t('Weekly'),
1 => $this->t('Daily'),
7 => $this->t('Weekly'),
],
'#description' => $this->t('Select how frequently you want to automatically check for new releases of your currently installed modules and themes.'),
];