You are here

public function JobScheduler::dispatch in Job Scheduler 7.2

Same name and namespace in other branches
  1. 7 JobScheduler.inc \JobScheduler::dispatch()

Dispatches a job.

Executes a worker callback or if schedule declares a queue name, queues a job for execution.

@codingStandardsIgnoreStart

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.

File

./JobScheduler.inc, line 150
JobScheduler class.

Class

JobScheduler
Manage scheduled jobs.

Code

public function dispatch($job) {

  // @codingStandardsIgnoreEnd
  $info = $this
    ->info();
  if (!$job['periodic']) {
    $this
      ->remove($job);
  }
  if (!empty($info['queue name'])) {
    if (DrupalQueue::get($info['queue name'])
      ->createItem($job)) {
      $this
        ->reserve($job);
    }
  }
  else {
    $this
      ->execute($job);
  }
}