Esempio n. 1
0
 /**
  * return the session-id that is bound to a specific job.
  *
  * @param string|null $job_guid
  * @return string|bool
  * @throws \Thallium\Controllers\ExceptionController if an error occurs.
  */
 protected function getSessionIdFromJob($job_guid = null)
 {
     global $thallium, $jobs;
     if (!isset($job_guid) || empty($job_guid)) {
         if (($job_guid = $jobs->getCurrentJob()) === false) {
             static::raiseError(get_class($jobs) . '::getCurrentJob() returned false!');
             return false;
         }
         if (!isset($job_guid) || empty($job_guid)) {
             static::raiseError(__METHOD__ . '(), no job found to work on!');
             return false;
         }
     }
     if (!$thallium->isValidGuidSyntax($job_guid)) {
         static::raiseError(get_class($thallium) . '::isValidGuidSyntax() returned false!');
         return false;
     }
     try {
         $job = new \Thallium\Models\JobModel(array(FIELD_GUID => $job_guid));
     } catch (\Exception $e) {
         static::raiseError(__METHOD__ . '(), failed to load JobModel!', false, $e);
         return false;
     }
     if (($sessionid = $job->getSessionId()) === false) {
         static::raiseError(get_class($job) . '::getSessionId() returned false!');
         return false;
     }
     return $sessionid;
 }