You are here

public function UpdateSettingsForm::buildForm in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/update/src/UpdateSettingsForm.php \Drupal\update\UpdateSettingsForm::buildForm()

Form constructor.

Parameters

array $form: An associative array containing the structure of the form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Return value

array The form structure.

Overrides ConfigFormBase::buildForm

File

core/modules/update/src/UpdateSettingsForm.php, line 51

Class

UpdateSettingsForm
Configure update settings for this site.

Namespace

Drupal\update

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $config = $this
    ->config('update.settings');
  $form['update_check_frequency'] = [
    '#type' => 'radios',
    '#title' => t('Check for updates'),
    '#default_value' => $config
      ->get('check.interval_days'),
    '#options' => [
      '1' => t('Daily'),
      '7' => t('Weekly'),
    ],
    '#description' => t('Select how frequently you want to automatically check for new releases of your currently installed modules and themes.'),
  ];
  $form['update_check_disabled'] = [
    '#type' => 'checkbox',
    '#title' => t('Check for updates of uninstalled modules and themes'),
    '#default_value' => $config
      ->get('check.disabled_extensions'),
  ];
  $notification_emails = $config
    ->get('notification.emails');
  $form['update_notify_emails'] = [
    '#type' => 'textarea',
    '#title' => t('Email addresses to notify when updates are available'),
    '#rows' => 4,
    '#default_value' => implode("\n", $notification_emails),
    '#description' => t('Whenever your site checks for available updates and finds new releases, it can notify a list of users via email. Put each address on a separate line. If blank, no emails will be sent.'),
  ];
  $form['update_notification_threshold'] = [
    '#type' => 'radios',
    '#title' => t('Email notification threshold'),
    '#default_value' => $config
      ->get('notification.threshold'),
    '#options' => [
      'all' => t('All newer versions'),
      'security' => t('Only security updates'),
    ],
    '#description' => t('You can choose to send email only if a security update is available, or to be notified about all newer versions. If there are updates available of Drupal core or any of your installed modules and themes, your site will always print a message on the <a href=":status_report">status report</a> page, and will also display an error message on administration pages if there is a security update.', [
      ':status_report' => Url::fromRoute('system.status')
        ->toString(),
    ]),
  ];
  return parent::buildForm($form, $form_state);
}