function AutomatedCronHooks::formSystemCronSettingsAlter

Same name and namespace in other branches
  1. 11.x core/modules/automated_cron/src/Hook/AutomatedCronHooks.php \Drupal\automated_cron\Hook\AutomatedCronHooks::formSystemCronSettingsAlter()

Implements hook_form_FORM_ID_alter() for the system_cron_settings() form.

Attributes

#[Hook('form_system_cron_settings_alter')]

File

core/modules/automated_cron/src/Hook/AutomatedCronHooks.php, line 46

Class

AutomatedCronHooks
Hook implementations for automated_cron.

Namespace

Drupal\automated_cron\Hook

Code

public function formSystemCronSettingsAlter(&$form, &$form_state) : void {
  $options = [
    3600,
    10800,
    21600,
    43200,
    86400,
    604800,
  ];
  $form['cron']['interval'] = [
    '#type' => 'select',
    '#title' => $this->t('Run cron every'),
    '#description' => $this->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',
    ]),
    '#config_target' => 'automated_cron.settings:interval',
    '#options' => [
      0 => $this->t('Never'),
    ] + array_map([
      \Drupal::service('date.formatter'),
      'formatInterval',
    ], array_combine($options, $options)),
  ];
}

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