private function TripalContentService_v0_1::addDocBundleCollectionClass
3.x TripalContentService_v0_1.inc | private TripalContentService_v0_1::addDocBundleCollectionClass($bundle, $term) |
Every content type (bundle) needs a collection class in the documentation.
1 call to TripalContentService_v0_1::addDocBundleCollectionClass()
- TripalContentService_v0_1::addDocBundleClasses in tripal_ws/
includes/ TripalWebService/ TripalContentService_v0_1.inc - Adds classes for every content type to the documentation for this service.
File
- tripal_ws/
includes/ TripalWebService/ TripalContentService_v0_1.inc, line 1261
Class
Code
private function addDocBundleCollectionClass($bundle, $term) {
$accession = preg_replace('/[^\w]/', '_', $bundle->label . ' Collection');
$details = array(
'id' => 'vocab:' . $accession,
'term' => 'vocab:' . $accession,
'title' => $bundle->label . ' Collection',
'subClassOf' => 'hydra:Collection',
'description' => 'A collection (or list) of ' . $bundle->label . ' resources.',
);
$vocab = tripal_get_vocabulary_details('hydra');
$properties = array();
$properties[] = array(
'type' => $vocab['sw_url'],
'title' => 'member',
'description' => "The list of available " . $bundle->label . '(s).',
"required" => null,
"readonly" => FALSE,
"writeonly" => FALSE,
);
$properties[] = array(
"type" => $vocab['sw_url'],
"title" => "totalItems",
"description" => "The total number of resources.",
"required" => null,
"readonly" => FALSE,
"writeonly" => FALSE
);
$properties[] = array(
"type" => $vocab['sw_url'],
"title" => "label",
"description" => "A label or name for the resource.",
"required" => null,
"readonly" => FALSE,
"writeonly" => FALSE
);
$class_id = $this->getServicePath() . '/' . urlencode($bundle->label);
$operations = array();
$operations['GET'] = array(
'label' => 'Retrieves a list of all ' . $bundle->label . ' resources.',
'description' => NULL,
'expects' => NULL,
'returns' => $term->url,
'type' => '_:' . preg_replace('/[^\w]/', '_', strtolower($bundle->label)) . '_collection_retrieve',
);
// If the user can create this content type then we allow a POST on the
// collection type.
if (user_access('create ' . $bundle->name)) {
$label = "Creates a " . $bundle->label;
if (preg_match('/^[aeiou]/i', $bundle->label)) {
$label = "Creates an " . $bundle->label;
}
// TODO: add this back in when web services support this method.
// $operations['POST'] = array(
// 'label' => $label,
// 'description' => NULL,
// 'expects' => $term->url,
// 'returns' => $term->url,
// 'type' => '_:' . preg_replace('/[^\w]/', '_', strtolower($bundle->label)) . '_create',
// 'statusCodes' => array(
// array(
// "code" => 201,
// "description" => "If the " . $bundle->label . " was created successfully."
// ),
// ),
// );
}
$this->addDocClass($details, $operations, $properties);
}