Example #1
0
 public function retrieveState($activity, $agent, $id)
 {
     if (!$activity instanceof Activity) {
         $activity = new Activity($activity);
     }
     if (!$agent instanceof Agent) {
         $agent = new Agent($agent);
     }
     $registration = null;
     $requestCfg = array('params' => array('activityId' => $activity->getId(), 'agent' => json_encode($agent->asVersion($this->version)), 'stateId' => $id), 'ignore404' => true);
     if (func_num_args() > 3) {
         $options = func_get_arg(3);
         if (isset($options)) {
             if (isset($options['registration'])) {
                 $requestCfg['params']['registration'] = $registration = $options['registration'];
             }
         }
     }
     $response = $this->sendRequest('GET', 'activities/state', $requestCfg);
     if ($response->success) {
         $doc = new State(array('id' => $id, 'content' => $response->content, 'activity' => $activity, 'agent' => $agent));
         if (isset($registration)) {
             $doc->setRegistration($registration);
         }
         if (isset($response->httpResponse['headers']['lastModified'])) {
             $doc->setTimestamp($response->httpResponse['headers']['lastModified']);
         }
         if (isset($response->httpResponse['headers']['contentType'])) {
             $doc->setContentType($response->httpResponse['headers']['contentType']);
         }
         if (isset($response->httpResponse['headers']['etag'])) {
             $doc->setEtag($response->httpResponse['headers']['etag']);
         }
         $response->content = $doc;
     }
     return $response;
 }