public function JobScheduler::execute in Job Scheduler 8.2
Same name and namespace in other branches
- 8.3 src/JobScheduler.php \Drupal\job_scheduler\JobScheduler::execute()
Executes a job.
Parameters
array $job: A $job array as passed into set() or read from job_schedule table.
Throws
\Exception Exceptions thrown by code called by this method are passed on.
Overrides JobSchedulerInterface::execute
1 call to JobScheduler::execute()
- JobScheduler::dispatch in src/
JobScheduler.php - Dispatches a job.
File
- src/
JobScheduler.php, line 126
Class
- JobScheduler
- Manage scheduled jobs.
Namespace
Drupal\job_schedulerCode
public function execute(array $job) {
$info = $this
->info($job['name']);
// If the job is periodic, re-schedule it before calling the worker.
if ($job['periodic']) {
$this
->reschedule($job);
}
if (!empty($info['file']) && file_exists($info['file'])) {
include_once $info['file'];
}
if (function_exists($info['worker callback'])) {
call_user_func($info['worker callback'], $job);
}
else {
$this
->remove($job);
throw new JobSchedulerException(t('Could not find worker callback function: @function', [
'@function' => $info['worker callback'],
]));
}
}