protected function Cron::invokeCronHandlers in Drupal 8
Same name and namespace in other branches
- 9 core/lib/Drupal/Core/Cron.php \Drupal\Core\Cron::invokeCronHandlers()
- 10 core/lib/Drupal/Core/Cron.php \Drupal\Core\Cron::invokeCronHandlers()
Invokes any cron handlers implementing hook_cron.
1 call to Cron::invokeCronHandlers()
File
- core/
lib/ Drupal/ Core/ Cron.php, line 210
Class
- Cron
- The Drupal core Cron service.
Namespace
Drupal\CoreCode
protected function invokeCronHandlers() {
$module_previous = '';
// If detailed logging isn't enabled, don't log individual execution times.
$time_logging_enabled = \Drupal::config('system.cron')
->get('logging');
$logger = $time_logging_enabled ? $this->logger : new NullLogger();
// Iterate through the modules calling their cron handlers (if any):
foreach ($this->moduleHandler
->getImplementations('cron') as $module) {
if (!$module_previous) {
$logger
->notice('Starting execution of @module_cron().', [
'@module' => $module,
]);
}
else {
$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) {
$logger
->notice('Execution of @module_previous_cron() took @time.', [
'@module_previous' => $module_previous,
'@time' => Timer::read('cron_' . $module_previous) . 'ms',
]);
}
}