public function JobScheduler::dispatch in Job Scheduler 7
Same name and namespace in other branches
- 7.2 JobScheduler.inc \JobScheduler::dispatch()
Dispatches a job.
Executes a worker callback or if schedule declares a queue name, queues a job for execution.
Parameters
$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.
File
- ./
JobScheduler.inc, line 139 - JobScheduler class.
Class
- JobScheduler
- Manage scheduled jobs.
Code
public function dispatch($job) {
$info = $this
->info();
if (!$job['periodic']) {
$this
->remove($job);
}
if ($info['queue name']) {
if (DrupalQueue::get($info['queue name'])
->createItem($job)) {
$this
->reserve($job);
}
}
elseif (function_exists($info['worker callback'])) {
$info['worker callback']($job);
}
}