You are here

public function SchedulerCronForm::generateRandomKey in Scheduler 2.x

Same name and namespace in other branches
  1. 8 src/Form/SchedulerCronForm.php \Drupal\scheduler\Form\SchedulerCronForm::generateRandomKey()

Form submission handler for the random key generation.

This only fires when the 'Generate new random key' button is clicked.

Parameters

array $form: An associative array containing the structure of the form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

File

src/Form/SchedulerCronForm.php, line 140

Class

SchedulerCronForm
Scheduler Lightweight Cron form.

Namespace

Drupal\scheduler\Form

Code

public function generateRandomKey(array &$form, FormStateInterface $form_state) {
  $config = $this
    ->config('scheduler.settings');
  $config
    ->set('lightweight_cron_access_key', substr(md5(rand()), 0, 20));
  $config
    ->save();
  parent::submitForm($form, $form_state);
}