Example #1
0
 /**
  * @param $jobId
  * @param $appId
  *
  * @return mixed
  */
 public static function actionJobGetResult($jobId, $appId = Producer::DEFAULT_APP_ID)
 {
     // sanitize user inputs
     $jobId = filter_var($jobId, FILTER_SANITIZE_STRING);
     $appId = filter_var($appId, FILTER_SANITIZE_STRING);
     /** @var AbstractJob $job */
     $job = AbstractJob::find($jobId, $appId);
     if (is_object($job)) {
         $result = $job->getResult();
         if ($result instanceof ResultException) {
             $response[self::P_RESPONSE_MSG] = 'Job result ' . $jobId;
             $response[self::P_RESPONSE_RESULT] = $result->toArray(true);
         } else {
             $response[self::P_RESPONSE_MSG] = 'Job result not ready : ' . $jobId;
         }
     } else {
         $response[self::P_RESPONSE_OK] = false;
         $response[self::P_RESPONSE_MSG] = 'Job not exists : ' . $jobId;
     }
     return $response;
 }