You are here

public function RestWSBaseFormat::queryResource in RESTful Web Services 7.2

Implements RestWSFormatInterface::queryResource().

Overrides RestWSFormatInterface::queryResource

2 methods override RestWSBaseFormat::queryResource()
RestWSFormatRDF::queryResource in ./restws.formats.inc
Implements RestWSFormatInterface::queryResource().
RestWSFormatXML::queryResource in ./restws.formats.inc
Overrides RestWSBaseFormat::queryResource().

File

./restws.formats.inc, line 161
RESTful web services module formats.

Class

RestWSBaseFormat
A base for all simple formats that are just serializing/unserializing an array of property values.

Code

public function queryResource($resourceController, $payload) {

  // Get the parameter from the URL.
  $parameters = drupal_get_query_parameters();
  $rest_controls = restws_meta_controls();
  $properties = $resourceController
    ->propertyInfo();
  $split_parameters = $this
    ->splitParameters($properties, $parameters);
  $values = $this
    ->generateQueryURIs($resourceController, $parameters, $split_parameters['filters']);
  $full = isset($split_parameters['meta_controls'][$rest_controls['full']]) ? $split_parameters['meta_controls'][$rest_controls['full']] : 1;
  $result = $resourceController
    ->query($split_parameters['filters'], $split_parameters['meta_controls']);
  $values['list'] = array();
  if ($full === '0') {
    foreach ($result as $id) {
      $values['list'][] = $this
        ->getResourceReference($resourceController
        ->resource(), $id);
    }
  }
  else {
    foreach ($result as $id) {
      $values['list'][] = $this
        ->getData($resourceController
        ->wrapper($id));
    }
  }
  $function = __FUNCTION__;
  drupal_alter('restws_response', $values, $function, $this->formatName, $resourceController);
  return $this
    ->serialize($values);
}