private function TripalContentService_v0_1::addDocBundleClasses
3.x TripalContentService_v0_1.inc | private TripalContentService_v0_1::addDocBundleClasses() |
Adds classes for every content type to the documentation for this service.
1 call to TripalContentService_v0_1::addDocBundleClasses()
- TripalContentService_v0_1::getDocumentation in tripal_ws/
includes/ TripalWebService/ TripalContentService_v0_1.inc
File
- tripal_ws/
includes/ TripalWebService/ TripalContentService_v0_1.inc, line 1070
Class
Code
private function addDocBundleClasses() {
global $user;
// Get the list of published terms (these are the bundle IDs)
$bundles = db_select('tripal_bundle', 'tb')
->fields('tb')
->orderBy('tb.label', 'ASC')
->execute();
// Iterate through the content types and add a class for each one.
$i = 0;
while ($bundle = $bundles->fetchObject()) {
$entity = entity_load('TripalTerm', array('id' => $bundle->term_id));
$term = reset($entity);
$vocab = $term->vocab;
// Get the bundle description. If no description is provided then
// use the term definition
$description = tripal_get_bundle_variable('description', $bundle->id);
if (!$description) {
$description = $term->getDefinition();
}
// Create the details array for the class.
$class_id = $this->getServicePath() . '/' . urlencode($bundle->label);
$details = array(
'id' => $term->getURL(),
'term' => $term->getAccession(),
'title' => preg_replace('/[^\w]/', '_', $bundle->label),
'description' => $description,
);
// Add in the supported operations for this content type.
$operations = array();
// If the user can view this content type.
if (user_access('view ' . $bundle->name)) {
$label = "Retrieves the " . $bundle->label . " resource.";
$operations['GET'] = array(
'label' => $label,
'description' => NULL,
'returns' => $term->url,
'type' => '_:' . preg_replace('/[^\w]/', '_', strtolower($bundle->label)) . '_retrieve',
);
}
// If the user can edit this content type.
if (user_access('edit ' . $bundle->name)) {
$label = "Update and replace the " . $bundle->label . " resource.";
if (preg_match('/^[aeiou]/i', $bundle->label)) {
$label = "Update and replace an " . $bundle->label . " resource.";
}
// TODO: add this back in when web services support this method.
// $operations['PUT'] = array(
// 'label' => $label,
// 'description' => NULL,
// 'returns' => $term->url,
// 'type' => '_:' . preg_replace('/[^\w]/', '_', strtolower($bundle->label)) . '_update',
// );
}
// If the user can edit this content type.
if (user_access('delete ' . $bundle->name)) {
$label = "Deletes the " . $bundle->label . " resource.";
if (preg_match('/^[aeiou]/i', $bundle->label)) {
$label = "Deletes an " . $bundle->label . " resource.";
}
// TODO: add this back in when web services support this method.
// $operations['DELETE'] = array(
// 'label' => $label,
// 'description' => NULL,
// 'returns' => $term->url,
// 'type' => '_:' . preg_replace('/[^\w]/', '_', strtolower($bundle->label)) . '_delete',
// );
}
// Add in the properties that correspond to fields in the data.
$properties = $this->addDocBundleFieldProperties($bundle, $term);
$this->addDocClass($details, $operations, $properties);
// Now add the bundle collection class.
$this->addDocBundleCollectionClass($bundle, $term);
} // end while ($bundle = $bundles->fetchObject()) { ...
}