automated_cron_form_system_cron_settings_alter(&$form, &$form_state)
Implements hook_form_FORM_ID_alter() for the system_cron_settings() form.
File
- core/modules/automated_cron/automated_cron.module, line 34
- Provides an automated cron by executing it at the end of a response.
Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | function automated_cron_form_system_cron_settings_alter(& $form , & $form_state ) { $automated_cron_settings = \Drupal::config( 'automated_cron.settings' ); // Add automated cron settings. $form [ 'automated_cron' ] = [ '#title' => t( 'Cron settings' ), '#type' => 'details' , '#open' => TRUE, ]; $options = [3600, 10800, 21600, 43200, 86400, 604800]; $form [ 'automated_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/cron' ]), '#default_value' => $automated_cron_settings ->get( 'interval' ), '#options' => [0 => t( 'Never' )] + array_map ([\Drupal::service( 'date.formatter' ), 'formatInterval' ], array_combine ( $options , $options )), ]; $form [ 'actions' ][ '#type' ] = 'actions' ; $form [ 'actions' ][ 'submit' ] = [ '#type' => 'submit' , '#value' => t( 'Save configuration' ), '#button_type' => 'primary' , ]; // Add submit callback. $form [ '#submit' ][] = 'automated_cron_settings_submit' ; // Theme this form as a config form. $form [ '#theme' ] = 'system_config_form' ; } |
Please login to continue.