You are here

function restws_resource_uri in RESTful Web Services 7.2

Same name and namespace in other branches
  1. 7 restws.module \restws_resource_uri()

Returns the URI used for the given resource.

Parameters

string $resource: The resource for which the URI should be returned.

int $id: The resource ID or NULL if only the base path should be returned.

array $options: Optional array that is passed to url().

7 calls to restws_resource_uri()
RestWSBaseFormat::generateQueryURIs in ./restws.formats.inc
Generates all navigation links for querying.
RestWSBaseFormat::getResourceReference in ./restws.formats.inc
RestWSFormatRDF::addReference in ./restws.formats.inc
RestWSFormatRDF::viewResource in ./restws.formats.inc
Gets the representation of a resource.
RestWSFormatXML::setXMLReference in ./restws.formats.inc

... See full list

File

./restws.module, line 452
RESTful web services module.

Code

function restws_resource_uri($resource, $id = NULL, array $options = array()) {
  $info = restws_get_resource_info($resource);
  $basepath = isset($info['menu_path']) ? $info['menu_path'] : $resource;
  $sub_path = isset($id) ? "/{$id}" : '';

  // Avoid having the URLs aliased.
  $base_options = array(
    'absolute' => TRUE,
    'alias' => TRUE,
  );
  $options += $base_options;
  return url($basepath . $sub_path, $options);
}