function CronForm::runCron

Same name in other branches
  1. 8.9.x core/modules/system/src/Form/CronForm.php \Drupal\system\Form\CronForm::runCron()
  2. 10 core/modules/system/src/Form/CronForm.php \Drupal\system\Form\CronForm::runCron()
  3. 11.x 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 166

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.'));
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.