TripalTerm.inc

File

tripal/includes/TripalTerm.inc
View source
  1. <?php
  2. /**
  3. * A class the controller will use for instantiating the TripalTerm entity.
  4. */
  5. class TripalTerm extends Entity {
  6. public function __construct($values = array()) {
  7. parent::__construct($values, 'TripalTerm');
  8. // Get the vocabulary for this term
  9. $vocab = entity_load('TripalVocab', array('id' => $this->vocab_id));
  10. $vocab = reset($vocab);
  11. $this->vocab = $vocab;
  12. // Get the term description from the storage backend
  13. $this->definition = NULL;
  14. $this->url = NULL;
  15. $term_details = tripal_get_term_details($vocab->vocabulary, $this->accession);
  16. if ($term_details) {
  17. if ($term_details and $term_details['definition']) {
  18. $this->definition = $term_details['definition'];
  19. }
  20. if ($term_details and $term_details['url']) {
  21. $this->url = $term_details['url'];
  22. }
  23. }
  24. }
  25. protected function defaultLabel() {
  26. return $this->name;
  27. }
  28. protected function defaultUri() {
  29. $vocab = 'TODO';
  30. return array('path' => '/vocabulary/' . $vocab . '/term/' . $this->id);
  31. }
  32. // Getters //
  33. public function getName() {
  34. return $this->name;
  35. }
  36. public function getAccession() {
  37. return $this->vocab->vocabulary . ':' . $this->accession;
  38. }
  39. public function getDefinition() {
  40. return $this->definition;
  41. }
  42. public function getURL() {
  43. return $this->url;
  44. }
  45. public function getVocab() {
  46. return $this->vocab;
  47. }
  48. public function getID() {
  49. return $this->id;
  50. }
  51. }