Example #1
0
 /**
  * Process the request according to the $requestType specified.
  *
  * @param \Trucker\Requests\RestRequest $request
  * @param string $requestType (GET/PUT/POST/DELETE)
  * @return bool Success of the request
  */
 protected function processRequest($request, $requestType)
 {
     if ($requestType != 'DELETE') {
         //set the property attributes on the request
         $request->setModelProperties($this);
     }
     $response = $this->sendRequest($request, $requestType);
     // if the response is invalid / doesn't work
     if ($response === false) {
         return false;
     }
     if ($requestType != 'DELETE') {
         //get the response and inflate from that
         $data = $response->parseResponseToData();
         $this->fill($data);
         //inflate the ID property that should be guarded
         //and thus not fillable
         $id = $this->getIdentityProperty();
         if (array_key_exists($id, $data)) {
             $this->{$id} = $data[$id];
         }
     }
     $this->doPostRequestCleanUp();
     return true;
 }