function automated_cron_form_system_cron_settings_alter

Same name and namespace in other branches
  1. 9 core/modules/automated_cron/automated_cron.module \automated_cron_form_system_cron_settings_alter()
  2. 8.9.x core/modules/automated_cron/automated_cron.module \automated_cron_form_system_cron_settings_alter()
  3. 10 core/modules/automated_cron/automated_cron.module \automated_cron_form_system_cron_settings_alter()

Implements hook_form_FORM_ID_alter() for the system_cron_settings() form.

File

core/modules/automated_cron/automated_cron.module, line 35

Code

function automated_cron_form_system_cron_settings_alter(&$form, &$form_state) {
    $automated_cron_settings = \Drupal::config('automated_cron.settings');
    $options = [
        3600,
        10800,
        21600,
        43200,
        86400,
        604800,
    ];
    $form['cron']['interval'] = [
        '#type' => 'select',
        '#title' => t('Run cron every'),
        '#description' => t('More information about setting up scheduled tasks can be found by <a href=":url">reading the cron tutorial on drupal.org</a>.', [
            ':url' => 'https://www.drupal.org/docs/8/administering-a-drupal-8-site/cron-automated-tasks',
        ]),
        '#default_value' => $automated_cron_settings->get('interval'),
        '#options' => [
            0 => t('Never'),
        ] + array_map([
            \Drupal::service('date.formatter'),
            'formatInterval',
        ], array_combine($options, $options)),
    ];
    // Add submit callback.
    $form['#submit'][] = 'automated_cron_settings_submit';
    // Theme this form as a config form.
    $form['#theme'] = 'system_config_form';
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.