You are here

public function SchedulerCronForm::runLightweightCron in Scheduler 2.x

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

Form submission handler to run the lightweight cron.

This only fires when "Run Scheduler's lightweight cron now" 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 157

Class

SchedulerCronForm
Scheduler Lightweight Cron form.

Namespace

Drupal\scheduler\Form

Code

public function runLightweightCron(array &$form, FormStateInterface $form_state) {
  $this->schedulerManager
    ->runLightweightCron([
    'admin_form' => TRUE,
  ]);
  if ($this->moduleHandler
    ->moduleExists('dblog')) {
    $url = Url::fromRoute('dblog.overview')
      ->toString();
    $message = $this
      ->t('Lightweight cron run completed. See the <a href="@url">log</a> for details.', [
      '@url' => $url,
    ]);
  }
  else {

    // If the Database Logging module is not enabled the route to the log
    // overview does not exist. Show a simple status message.
    $message = $this
      ->t('Lightweight cron run completed.');
  }
  $this
    ->messenger()
    ->addMessage($message);
}