TripalContentTypeService.inc 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. class TripalContentTypeService extends TripalWebService {
  3. public static $label = 'Content Types';
  4. public static $description = 'Provides acesss to the biological and ' .
  5. 'ancilliary data available on this site. Each content type represents ' .
  6. 'biological data that is defined in a controlled vocabulary (e.g. ' .
  7. 'Sequence Ontology term: gene (SO:0000704)).'
  8. public static $name = 'content';
  9. public function __construct() {
  10. parent::__construct();
  11. // Iterate through all of the entitie types (bundles) and add them as
  12. // supported classes.
  13. $bundles = db_select('tripal_bundle', 'tb')
  14. ->fields('tb')
  15. ->orderBy('tb.label', 'ASC')
  16. ->execute();
  17. // Iterate through the terms and add an entry in the collection.
  18. $i = 0;
  19. while ($bundle = $bundles->fetchObject()) {
  20. $entity = entity_load('TripalTerm', array('id' => $bundle->term_id));
  21. $term = reset($entity);
  22. $vocab = $term->vocab;
  23. // Get the bundle description. If no description is provided then
  24. // use the term definition
  25. $description = tripal_get_bundle_variable('description', $bundle->id);
  26. if (!$description) {
  27. $description = $term->definition;
  28. }
  29. // Add the bundle as a content type.
  30. // $response['member'][] = array(
  31. // '@id' => url($api_url . '/content/' . urlencode($bundle->label), array('absolute' => TRUE)),
  32. // '@type' => $term->name,
  33. // 'label' => $bundle->label,
  34. // 'description' => $description,
  35. // );
  36. $operations = array();
  37. $properties = array();
  38. $this->addSupportedClass($term->name, $bundle->label, $description, $operations, $properties);
  39. $this->addContextItem($term->name, $term->url);
  40. }
  41. }
  42. }