Exemplo n.º 1
0
 /**
  * @param Job $job
  * @param int $priority
  * @param int $delay (seconds)
  * @return Job
  */
 public static function create(Job $job, $priority = Job::PRIORITY_NORMAL, $delay = 0)
 {
     $job->setDateCreated(new \DateTime());
     $job->setDateUpdated(new \DateTime());
     $job->setStatus(0);
     $job = self::save($job);
     $job = self::queue($job, $priority, $delay);
     return $job;
 }
Exemplo n.º 2
0
 /**
  * @param Job $job
  * @param int $priority
  * @param int $delay (seconds)
  * @return Job
  */
 public static function create(Job $createJob, $priority = Job::PRIORITY_NORMAL, $delay = 0)
 {
     $createJob->setDateCreated(new \DateTime());
     $createJob->setDateUpdated(new \DateTime());
     $createJob->setStatus(0);
     if (!$createJob->getData()) {
         $createJob->setData([]);
     }
     $job = self::save($createJob);
     if (is_null($job)) {
         $newData = $createJob->toArray();
         unset($newData['id']);
         $job = self::save(new Job($newData));
         if (is_null($job)) {
             throw new \Exception('Failed to create job: ' . $createJob->getType());
         }
     }
     $job = self::queue($job, $priority, $delay);
     return $job;
 }