You are here

public function CronForm::runCron in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/system/src/Form/CronForm.php \Drupal\system\Form\CronForm::runCron()

Form submission handler for running cron manually.

File

core/modules/system/src/Form/CronForm.php, line 165

Class

CronForm
Configure cron settings for this site.

Namespace

Drupal\system\Form

Code

public function runCron(array &$form, FormStateInterface $form_state) {
  if ($this->cron
    ->run()) {
    $this
      ->messenger()
      ->addStatus($this
      ->t('Cron ran successfully.'));
  }
  else {
    $this
      ->messenger()
      ->addError($this
      ->t('Cron run failed.'));
  }
}