You are here

public function JobExecutor::save in Apigee Edge 8

Saves a job.

Parameters

\Drupal\apigee_edge\Job\Job $job: Job object.

Throws

\Exception

Overrides JobExecutorInterface::save

3 calls to JobExecutor::save()
JobExecutor::call in src/JobExecutor.php
Executes a job synchronously.
JobExecutor::cast in src/JobExecutor.php
Executes a job asynchronously.
JobExecutor::ensure in src/JobExecutor.php
Ensures that a job exists with a given status.

File

src/JobExecutor.php, line 87

Class

JobExecutor
Job executor service.

Namespace

Drupal\apigee_edge

Code

public function save(Job $job) {
  $now = $this->time
    ->getCurrentTime();
  $jobdata = serialize($job);
  $fields = [
    'status' => $job
      ->getStatus(),
    'job' => $jobdata,
    'updated' => $now,
    'tag' => $job
      ->getTag(),
  ];
  $this->connection
    ->merge('apigee_edge_job')
    ->key('id', $job
    ->getId())
    ->insertFields([
    'id' => $job
      ->getId(),
    'created' => $now,
  ] + $fields)
    ->updateFields($fields)
    ->execute();
}