tripal_cv.organism.inc 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. /**
  3. *
  4. *
  5. */
  6. class TrpOrganismController extends DrupalDefaultEntityController {
  7. /**
  8. *
  9. * @param $ids
  10. * An array of entity IDs, or FALSE to load all entities.
  11. * @param $conditions
  12. * DEPRECATED. An array of conditions. Keys are field names on the entity's
  13. * base table.Values will be compared for equality. All the comparisons will
  14. * be ANDed together. This parameter is deprecated; use an EntityFieldQuery
  15. * instead.
  16. * @return multitype:An
  17. */
  18. public function load($ids = array(), $conditions = array()) {
  19. $entities = array();
  20. $queried_entities = array();
  21. $values = array('organism_id' => $ids);
  22. $options = array('return_array' => TRUE);
  23. $organisms = chado_generate_var('organism', $values, $options);
  24. $organisms = chado_expand_var($organisms, 'field', 'organism.comment');
  25. foreach ($organisms as $result) {
  26. $organism = new stdClass();
  27. $organism->internal_id = $result->organism_id;
  28. // Add the names by which this feature is known.
  29. $names = array();
  30. $names[] = $result->genus . ' ' . $result->species;
  31. $names[] = $result->common_name;
  32. $names[] = $result->abbreviation;
  33. $organism->name = array_unique($names);
  34. // Add in properties.
  35. // Add in the expand array.
  36. $expand = array();
  37. $organism->expand = $expand;
  38. // Add in the embeded elements.
  39. $embedded = array();
  40. $organism->embedded = $embedded;
  41. // Add in site-specific properties.
  42. $organism->genus = $result->genus;
  43. $organism->species = $result->species;
  44. $organism->description = $result->comment;
  45. // Add in the phylogeny if the NCBI taxonomy is loaded.
  46. $queried_entities[$organism->internal_id] = $organism;
  47. }
  48. // Pass all entities loaded from the database through $this->attachLoad(),
  49. // which attaches fields (if supported by the entity type) and calls the
  50. // entity type specific load callback, for example hook_node_load().
  51. if (!empty($queried_entities)) {
  52. // $this->attachLoad($queried_entities);
  53. $entities += $queried_entities;
  54. }
  55. // Ensure that the returned array is ordered the same as the original
  56. // $ids array if this was passed in and remove any invalid ids.
  57. return $entities;
  58. }
  59. }