You are here

function uuid_term_features_export_options in UUID Features Integration 7

Same name and namespace in other branches
  1. 6 includes/uuid_term.features.inc \uuid_term_features_export_options()

Implements hook_features_export_options().

File

includes/uuid_term.features.inc, line 11
Features hooks for the uuid_term features component.

Code

function uuid_term_features_export_options() {
  $options = array();

  // Check what vocabularies are enabled for uuid features export.
  $vocabs = array();
  $entity_info = entity_get_info('taxonomy_term');
  foreach ($entity_info['bundles'] as $key => $value) {
    if (variable_get("uuid_features_entity_taxonomy_term_{$key}", FALSE)) {
      $vocabs[$key] = $key;
    }
  }
  if (!empty($vocabs)) {
    $query = db_select('taxonomy_term_data', 't');
    $query
      ->innerJoin('taxonomy_vocabulary', 'v', 't.vid = v.vid');
    $query
      ->condition('v.machine_name', array_keys($vocabs))
      ->fields('t', array(
      'tid',
      'name',
      'uuid',
    ))
      ->addField('v', 'name', 'vname');
    $query
      ->orderBy('v.name', 'ASC');
    $query
      ->orderBy('t.name', 'ASC');
    $query
      ->addTag('uuid_term_features_export_options');
    $results = $query
      ->execute()
      ->fetchAll();
    foreach ($results as $term) {
      $options[$term->uuid] = $term->vname . ' - ' . $term->name;
    }
  }
  drupal_alter('uuid_term_features_export_options', $options);
  return $options;
}