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

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
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
2025-01-10 15:47:30
Comments
Leave a Comment

Please login to continue.