You are here

function cronkeychange_generate_submit in Cron key change 2.x

Same name and namespace in other branches
  1. 8 cronkeychange.module \cronkeychange_generate_submit()
  2. 7 cronkeychange.module \cronkeychange_generate_submit()

Generate new cron key.

1 call to cronkeychange_generate_submit()
CronKeyChangeCommands::cronkeychange in src/Commands/CronKeyChangeCommands.php
Generate new cron key.
1 string reference to 'cronkeychange_generate_submit'
cronkeychange_form_system_cron_settings_alter in ./cronkeychange.module
Implements hook_form_FORM_ID_alter().

File

./cronkeychange.module, line 39
Cron Key Change.

Code

function cronkeychange_generate_submit(&$form = [], &$form_state = []) {
  $cron_key = Crypt::randomBytesBase64(55);
  \Drupal::state()
    ->set('system.cron_key', $cron_key);
  if (PHP_SAPI !== 'cli') {
    \Drupal::messenger()
      ->addMessage(t('New cron key generated.'));
  }
  \Drupal::logger('cronkeychange')
    ->notice('New cron key generated.');
}