function tripal_ws_list_services
3.x tripal_ws.module | tripal_ws_list_services() |
Generates the list of services as the "home page" for Tripal web services.
Related topics
1 call to tripal_ws_list_services()
- tripal_ws_get_services in tripal_ws/
tripal_ws.module - The callback function for all RESTful web services.
File
- tripal_ws/
tripal_ws.module, line 222 - The Tripal Web Service Module
Code
function tripal_ws_list_services() {
global $base_url;
$base_path = $base_url . '/web-services';
// Create an instance of the TriaplWebService class and use it to build
// the entry point for the web serivces.
$service = new TripalWebService($base_path);
// Get the list of web service classes.
$services = tripal_get_web_services();
// Create the parent resource which is a collection.
$resource = new TripalWebServiceResource($base_path);
// Add the vocabulary to the context.
tripal_load_include_web_service_class('TripalDocService_v0_1');
$service = new TripalDocService_v0_1($base_path);
$resource->addContextItem('vocab', $service->getServicePath() . '#');
$resource->addContextItem('EntryPoint', 'vocab:EntryPoint');
$resource->setType('EntryPoint');
// Now add the services as properties.
foreach ($services as $service_class) {
tripal_load_include_web_service_class($service_class);
if ($service_class == 'TripalDocService_v0_1') {
continue;
}
$service = new $service_class($base_path);
$resource->addContextItem($service_class::$type, array(
'@id' => 'vocab:EntryPoint/' . $service_class::$type,
'@type' => '@id',
));
$resource->addProperty($service_class::$type, $service->getServicePath());
}
$service->setResource($resource);
$response = $service->getResponse();
print drupal_json_encode($response);
}