You are here

public function OgVocabMigrate::getTaxonomyFields in OG Vocabulary 7

Helper function; Get the field names of term references in node entity.

Return value

Array of field names for the given bundle.

1 call to OgVocabMigrate::getTaxonomyFields()
OgVocabMigrate::__construct in includes/migrate/og_vocab.migrate.inc
General initialization of a Migration object.

File

includes/migrate/og_vocab.migrate.inc, line 163
Migrate plugin to populate the OG vocabulary field by the term references.

Class

OgVocabMigrate
@file Migrate plugin to populate the OG vocabulary field by the term references.

Code

public function getTaxonomyFields() {
  $field_names =& drupal_static(__METHOD__, array());
  $bundle = $this->bundle;
  if (isset($field_names[$bundle])) {
    return $field_names[$bundle];
  }
  $field_names[$bundle] = array();
  foreach (field_info_instances('node', $bundle) as $field_name => $instance) {
    $field = field_info_field($field_name);
    if ($field['type'] != 'taxonomy_term_reference') {

      // Field is not taxonomy reference.
      continue;
    }
    $vocabulary = taxonomy_vocabulary_machine_name_load($field['settings']['allowed_values'][0]['vocabulary']);
    if (!og_vocab_relation_get($vocabulary->vid)) {

      // field is not referencing a vocabaulry that is associated
      // with a group.
      continue;
    }
    $field_names[$bundle][] = $field['field_name'];
  }
  return $field_names[$bundle];
}