function automatic_updates_form_update_settings_alter in Automatic Updates 8.2
Implements hook_form_FORM_ID_alter() for 'update_settings' form.
File
- ./
automatic_updates.module, line 94 - Contains hook implementations for Automatic Updates.
Code
function automatic_updates_form_update_settings_alter(array &$form, FormStateInterface $form_state, string $form_id) {
$recommender = new UpdateRecommender();
$drupal_project = $recommender
->getProjectInfo();
$version = ExtensionVersion::createFromVersionString($drupal_project['existing_version']);
$current_minor = $version
->getMajorVersion() . '.' . $version
->getMinorVersion();
$supported_until_version = $version
->getMajorVersion() . '.' . ((int) $version
->getMinorVersion() + ProjectSecurityData::CORE_MINORS_WITH_SECURITY_COVERAGE) . '.0';
$form['automatic_updates_cron'] = [
'#type' => 'radios',
'#title' => t('Automatically update Drupal core'),
'#options' => [
CronUpdater::DISABLED => t('Disabled'),
CronUpdater::ALL => t('All supported updates'),
CronUpdater::SECURITY => t('Security updates only'),
],
'#default_value' => \Drupal::config('automatic_updates.settings')
->get('cron'),
'#description' => t('If enabled, Drupal core will be automatically updated when an update is available. Automatic updates are only supported for @current_minor.x versions of Drupal core. Drupal @current_minor will receive security updates until @supported_until_version is released.', [
'@current_minor' => $current_minor,
'@supported_until_version' => $supported_until_version,
]),
];
$form += [
'#submit' => [
'::submitForm',
],
];
$form['#submit'][] = '_automatic_updates_update_settings_form_submit';
}