Cron::invokeCronHandlers

protected Cron::invokeCronHandlers()

Invokes any cron handlers implementing hook_cron.

File

core/lib/Drupal/Core/Cron.php, line 196

Class

Cron
The Drupal core Cron service.

Namespace

Drupal\Core

Code

protected function invokeCronHandlers() {
  $module_previous = '';

  // Iterate through the modules calling their cron handlers (if any):
  foreach ($this->moduleHandler->getImplementations('cron') as $module) {

    if (!$module_previous) {
      $this->logger->notice('Starting execution of @module_cron().', [
        '@module' => $module,
      ]);
    }
    else {
      $this->logger->notice('Starting execution of @module_cron(), execution of @module_previous_cron() took @time.', [
        '@module' => $module,
        '@module_previous' => $module_previous,
        '@time' => Timer::read('cron_' . $module_previous) . 'ms',
      ]);
    }
    Timer::start('cron_' . $module);

    // Do not let an exception thrown by one module disturb another.
    try {
      $this->moduleHandler->invoke($module, 'cron');
    }
    catch (\Exception $e) {
      watchdog_exception('cron', $e);
    }

    Timer::stop('cron_' . $module);
    $module_previous = $module;
  }
  if ($module_previous) {
    $this->logger->notice('Execution of @module_previous_cron() took @time.', [
      '@module_previous' => $module_previous,
      '@time' => Timer::read('cron_' . $module_previous) . 'ms',
    ]);
  }
}
doc_Drupal
2016-10-29 08:59:05
Comments
Leave a Comment

Please login to continue.