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: update.settings:
type: config_object type: config_object
label: 'Update settings' label: 'Update settings'
constraints:
FullyValidatable: ~
mapping: mapping:
check: check:
type: mapping type: mapping
@ -14,6 +16,10 @@ update.settings:
interval_days: interval_days:
type: integer type: integer
label: 'Days since last check' label: 'Days since last check'
constraints:
# @see \Drupal\update\UpdateSettingsForm::buildForm()
# The options are daily and weekly.
Choice: [1, 7]
fetch: fetch:
type: mapping type: mapping
label: 'Fetch settings' label: 'Fetch settings'
@ -25,9 +31,15 @@ update.settings:
max_attempts: max_attempts:
type: integer type: integer
label: 'Maximum attempts' label: 'Maximum attempts'
constraints:
Range:
min: 1
timeout: timeout:
type: integer type: integer
label: 'Timeout in seconds' label: 'Timeout in seconds'
constraints:
Range:
min: 1
notification: notification:
type: mapping type: mapping
label: 'Notification settings' label: 'Notification settings'
@ -41,3 +53,6 @@ update.settings:
threshold: threshold:
type: string type: string
label: 'Email notification threshold' 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/threshold': update_notification_threshold
'notification/emails': update_notify_emails 'notification/emails': update_notify_emails
'check/interval_days': update_check_frequency 'check/interval_days': update_check_frequency
'check/disabled_extensions':
plugin: default_value
default_value: false
'fetch/timeout':
plugin: default_value
default_value: 30
destination: destination:
plugin: config plugin: config
config_name: update.settings config_name: update.settings

View File

@ -36,10 +36,13 @@ class UpdateSettingsForm extends ConfigFormBase {
$form['update_check_frequency'] = [ $form['update_check_frequency'] = [
'#type' => 'radios', '#type' => 'radios',
'#title' => $this->t('Check for updates'), '#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' => [ '#options' => [
'1' => $this->t('Daily'), 1 => $this->t('Daily'),
'7' => $this->t('Weekly'), 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.'), '#description' => $this->t('Select how frequently you want to automatically check for new releases of your currently installed modules and themes.'),
]; ];