You are here

function _taxonomy_entity_index_get_terms_array in Taxonomy Entity Index 7

Same name and namespace in other branches
  1. 8 includes/taxonomy_entity_index.tokens.inc \_taxonomy_entity_index_get_terms_array()
1 call to _taxonomy_entity_index_get_terms_array()
taxonomy_entity_index_tokens in ./taxonomy_entity_index.tokens.inc
Implements hook_tokens().

File

./taxonomy_entity_index.tokens.inc, line 83
Token integration for the taxonomy_entity_index module.

Code

function _taxonomy_entity_index_get_terms_array($entity_type, $entity) {
  list($entity_id, $revision_id) = entity_extract_ids($entity_type, $entity);

  // @todo How to properly 'order' these by field/delta?
  $tids = db_query("SELECT tid FROM {taxonomy_entity_index} WHERE entity_type = :type AND entity_id = :id AND revision_id = :vid ORDER BY delta", array(
    ':type' => $entity_type,
    ':id' => $entity_id,
    ':vid' => isset($revision_id) ? $revision_id : $entity_id,
  ))
    ->fetchCol();
  $terms = taxonomy_term_load_multiple($tids);
  foreach ($terms as $tid => $term) {
    $terms[$tid] = $term->name;
  }
  return $terms;
}