function tripal_load_vocab_entity
3.x tripal.entities.api.inc | tripal_load_vocab_entity($values) |
Retrieves a TripalVocab entity that maches the given arguments.
Parameters
$values: An associative array used to match a vocabulary. The valid keys are:
- vocab_id: integer id of the vocabulary.
- vocabulary: string name of vocabulary.
Return value
A TripalVocab entity object or NULL if not found.
Related topics
2 calls to tripal_load_vocab_entity()
- tripal_chado_bundle_create in tripal_chado/
includes/ tripal_chado.bundle.inc - tripal_create_bundle in tripal/
api/ tripal.entities.api.inc - Creates a new Tripal Entity type (i.e. bundle).
File
- tripal/
api/ tripal.entities.api.inc, line 297 - Provides an application programming interface (API) for working with TripalEntity content types (bundles) and their entities.
Code
function tripal_load_vocab_entity($values) {
$vocabulary = array_key_exists('vocabulary', $values) ? $values['vocabulary'] : '';
$vocab_id = array_key_exists('vocab_id', $values) ? $values['vocab_id'] : '';
$vocab = NULL;
$query = db_select('tripal_vocab', 'tv')
->fields('tv');
if ($vocabulary) {
$query->condition('tv.vocabulary', $vocabulary);
}
if ($vocab_id) {
$query->condition('tv.id', $vocab_id);
}
$vocab = $query->execute()->fetchObject();
if ($vocab) {
$entity = entity_load('TripalVocab', array($vocab->id));
return reset($entity);
}
return NULL;
}