public static function unserialize($array) { $job = new Job($array['task'], $array['workload']); $job->setUUID($array['uuid']); if (isset($array['jobhandler'])) { $job->setJobHandler($array['jobhandler']); } if (isset($array['status'])) { $job->setStatus($array['status']); } if (isset($array['result'])) { $job->setResult($array['result']); } return $job; }
public function run(Job $job, $run = self::RUN_NORMAL) { try { $this->job($job->getUUID()); } catch (Exception $e) { $this->save($job); } if ($run == self::RUN_BACKGROUND) { // the command run and save the job after his creation in gearman // with the jobhandler to, next, get the status $process = $this->console->execute(new RunJobCommand(), ['uuid' => $job->getUUID()]); } else { $result = $this->client->doNormal($job->getTask(), $job->getWorkload(Job::WORKLOAD_JSON)); $job->setResult($result); $this->save($job); } }