tripal_cv.entities.inc 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. require_once 'tripal_cv.vocabulary.inc';
  3. require_once 'tripal_cv.vocabulary_term.inc';
  4. require_once 'tripal_cv.organism.inc';
  5. require_once 'tripal_cv.feature.inc';
  6. /**
  7. * Implements hook_entity_info().
  8. */
  9. function tripal_cv_entity_info() {
  10. $entities = array();
  11. // The vocabulary and vocabulary term entities.
  12. $entities['trp_vocabulary'] = array(
  13. 'label' => t('Controlled Vocabulary'),
  14. 'plural label' => t('Controlled Vocabularies'),
  15. 'entity class' => 'TrpVocabulary',
  16. 'controller class' => 'TrpVocabularyController',
  17. 'entity keys' => array(
  18. 'id' => 'internal_id'
  19. ),
  20. );
  21. $entities['trp_vocabulary_term'] = array(
  22. 'label' => t('Controlled Vocabulary Term'),
  23. 'plural label' => t('Controlled Vocabulary Terms'),
  24. 'entity class' => 'TrpVocabularyTerm',
  25. 'controller class' => 'TrpVocabularyTermController',
  26. 'entity keys' => array(
  27. 'id' => 'internal_id'
  28. ),
  29. );
  30. // We want to dynamically add entities for terms specifically set
  31. // by the site admin
  32. $values = array(
  33. 'cv_id' => array(
  34. 'name' => 'sequence'
  35. ),
  36. 'name' => 'gene'
  37. );
  38. $cvterm = chado_generate_var('cvterm', $values);
  39. $entity_id = 'trp_' . $cvterm->dbxref_id->db_id->name . '_' . $cvterm->dbxref_id->accession;
  40. $label = preg_replace('/_/', ' ', ucwords($cvterm->name));
  41. $plural_label = $label . '(s)';
  42. $entity_class = 'TrpTerm' . $entity_id;
  43. $entities[$entity_id] = array(
  44. 'label' => $label,
  45. 'plural label' => $plural_label,
  46. 'entity class' => $entity_class,
  47. 'controller class' => 'TrpFeatureController',
  48. 'entity keys' => array(
  49. 'id' => 'internal_id'
  50. ),
  51. );
  52. // The organism entity.
  53. $entities['trp_organism'] = array(
  54. 'label' => t('Organism'),
  55. 'plural label' => t('Organism'),
  56. 'entity class' => 'TrpOrganism',
  57. 'controller class' => 'TrpOrganismController',
  58. 'entity keys' => array(
  59. 'id' => 'internal_id'
  60. ),
  61. );
  62. return $entities;
  63. }