You are here

protected function EntityShareServerRestAbstract::parseRequest in Entity Share 7

Parse the request.

Return value

bool TRUE if the request is valid, FALSE otherwise.

1 call to EntityShareServerRestAbstract::parseRequest()
EntityShareServerRestAbstract::__construct in modules/entity_share_server/includes/entity_share_server.rest.abstract.inc
Constructor. Initialize properties.

File

modules/entity_share_server/includes/entity_share_server.rest.abstract.inc, line 277
Class for handling Entity Share Rest Server request.

Class

EntityShareServerRestAbstract
Abstract Class to manage the EntityShare Rest server.

Code

protected function parseRequest() {
  $request = $this
    ->getDefaultRequest();
  switch ($this
    ->getRequestMethod()) {
    case 'POST':
    case 'PUT':
      $raw_data = file_get_contents('php://input');
      if (strstr($_SERVER['CONTENT_TYPE'], 'application/json')) {
        $request['datas'] = (object) drupal_json_decode($raw_data);
      }
      else {
        return FALSE;
      }
      break;
    case 'GET':
    case 'DELETE':
      break;
    default:
      $this
        ->setError('HTTP Method not managed');
      return FALSE;
  }
  $this->request = $request;
  return TRUE;
}