Example #1
0
 /**
  * @param JobQueue           $queue
  * @param array              $newJob
  * @return bool
  * @throws \InvalidArgumentException
  * @throws \Exception
  */
 public static function addJob(JobQueue $queue, $newJob)
 {
     if (empty($newJob)) {
         throw new \InvalidArgumentException("Invalid job data.");
     }
     $status = false;
     try {
         $queue->beforeAdd($newJob);
         $status = $queue->addJob($newJob);
         $queue->afterAdd();
     } catch (\Exception $ex) {
         $queue->onError($ex);
         throw $ex;
     }
     return $status;
 }