function tripal_load_bundle_entity

3.x tripal.entities.api.inc tripal_load_bundle_entity($values)

Retrieves a TripalBundle entity that matches the given arguments.

Parameters

$values: An associative array used to match a bundle. Valid keys may:

  • id: the numeric id of the bundle.
  • name: the bundle name (e.g. 'bio_data_234')
  • label: the bundle label (e.g. 'Organism')
  • term_id: the term ID to which the bundle belongs

Return value

A TripalBundle entity object or NULL if not found.

Related topics

49 calls to tripal_load_bundle_entity()
chado_publish_records in tripal_chado/api/tripal_chado.api.inc
Publishes content in Chado as a new TripalEntity entity.
content_type::load in tripal/includes/TripalFields/content_type/content_type.inc
rdfs__type::load in tripal/includes/TripalFields/rdfs__type/rdfs__type.inc
remote__data::instanceSettingsForm in tripal_ws/includes/TripalFields/remote__data/remote__data.inc
remote__data::load in tripal_ws/includes/TripalFields/remote__data/remote__data.inc

... See full list

File

tripal/api/tripal.entities.api.inc, line 335
Provides an application programming interface (API) for working with TripalEntity content types (bundles) and their entities.

Code

function tripal_load_bundle_entity($values) {

  $query = db_select('tripal_bundle', 'tb');
  $query->fields('tb');
  if (array_key_exists('id', $values)) {
    $query->condition('tb.id', $values['id']);
  }
  if (array_key_exists('name', $values)) {
    $query->condition('tb.name', $values['name']);
  }
  if (array_key_exists('label', $values)) {
    $query->condition('tb.label', $values['label']);
  }
  if (array_key_exists('term_id', $values)) {
    $query->condition('tb.term_id', $values['term_id']);
  }
  $bundle = $query->execute()->fetchObject();

  if ($bundle) {
    $entity = entity_load_unchanged('TripalBundle', $bundle->id);
    return $entity;
  }
  return NULL;
}