You are here

function _entity_translation_taxonomy_reference_get_vocabulary in Entity Translation 7

Returns the vocabulary enabled for the specified taxonomy reference field.

Parameters

array $field: A field definition.

Return value

object|null A vocabulary object or NULL if none is found.

2 calls to _entity_translation_taxonomy_reference_get_vocabulary()
entity_translation_taxonomy_autocomplete_validate in ./entity_translation.taxonomy.inc
Form element validate handler for taxonomy term autocomplete element.
entity_translation_taxonomy_term_autocomplete in ./entity_translation.taxonomy.inc
Entity translation taxonomy autocomplete callback.

File

./entity_translation.taxonomy.inc, line 386
The taxonomy specific translation functions and hook implementations.

Code

function _entity_translation_taxonomy_reference_get_vocabulary($field) {
  $vocabulary = NULL;
  if (!empty($field['settings']['allowed_values'])) {
    $vids = array();
    $vocabularies = taxonomy_vocabulary_get_names();
    foreach ($field['settings']['allowed_values'] as $tree) {
      $vids[] = $vocabularies[$tree['vocabulary']]->vid;
    }
    $vocabulary = taxonomy_vocabulary_load(reset($vids));
  }
  return $vocabulary;
}