Security update for Core, with self-updated composer
[yaffs-website] / web / core / modules / system / src / Form / CronForm.php
index d4726aac575220a81e8f8dcbc6dd8844716d5c2a..3957060e109a0414d4fe281480e3565168d583c7 100644 (file)
@@ -16,6 +16,7 @@ use Drupal\Core\Form\ConfigFormBaseTrait;
  * Configure cron settings for this site.
  */
 class CronForm extends FormBase {
+
   use ConfigFormBaseTrait;
 
   /**
@@ -42,7 +43,7 @@ class CronForm extends FormBase {
   /**
    * The module handler service.
    *
-   * @var \Drupal\Core\Extension\ModuleHandlerInterface $moduleHandler
+   * @var \Drupal\Core\Extension\ModuleHandlerInterface
    */
   protected $moduleHandler;
 
@@ -104,6 +105,7 @@ class CronForm extends FormBase {
     $form['run'] = [
       '#type' => 'submit',
       '#value' => t('Run cron'),
+      '#submit' => ['::runCron'],
     ];
     $status = '<p>' . $this->t('Last run: %time ago.', ['%time' => $this->dateFormatter->formatTimeDiffSince($this->state->get('system.cron_last'))]) . '</p>';
     $form['status'] = [
@@ -112,7 +114,7 @@ class CronForm extends FormBase {
 
     $cron_url = $this->url('system.cron', ['key' => $this->state->get('system.cron_key')], ['absolute' => TRUE]);
     $form['cron_url'] = [
-      '#markup' => '<p>' . t('To run cron from outside the site, go to <a href=":cron">@cron</a>', [':cron' => $cron_url, '@cron' => $cron_url]) . '</p>',
+      '#markup' => '<p>' . t('To run cron from outside the site, go to <a href=":cron" class="system-cron-settings__link">@cron</a>', [':cron' => $cron_url, '@cron' => $cron_url]) . '</p>',
     ];
 
     if (!$this->moduleHandler->moduleExists('automated_cron')) {
@@ -131,7 +133,7 @@ class CronForm extends FormBase {
       '#type' => 'checkbox',
       '#title' => t('Detailed cron logging'),
       '#default_value' => $this->config('system.cron')->get('logging'),
-      '#description' => 'Run times of individual cron jobs will be written to watchdog',
+      '#description' => $this->t('Run times of individual cron jobs will be written to watchdog'),
     ];
 
     $form['actions']['#type'] = 'actions';
@@ -145,22 +147,25 @@ class CronForm extends FormBase {
   }
 
   /**
-   * Runs cron and reloads the page.
+   * {@inheritdoc}
    */
   public function submitForm(array &$form, FormStateInterface $form_state) {
     $this->config('system.cron')
       ->set('logging', $form_state->getValue('logging'))
       ->save();
     drupal_set_message(t('The configuration options have been saved.'));
+  }
 
-    // Run cron manually from Cron form.
+  /**
+   * Form submission handler for running cron manually.
+   */
+  public function runCron(array &$form, FormStateInterface $form_state) {
     if ($this->cron->run()) {
-      drupal_set_message(t('Cron ran successfully.'));
+      drupal_set_message($this->t('Cron ran successfully.'));
     }
     else {
-      drupal_set_message(t('Cron run failed.'), 'error');
+      drupal_set_message($this->t('Cron run failed.'), 'error');
     }
-
   }
 
 }