You are here

function taxonomy_feeds_get_source in Feeds 7.2

Same name and namespace in other branches
  1. 8.2 mappers/taxonomy.inc \taxonomy_feeds_get_source()
  2. 6 mappers/taxonomy.inc \taxonomy_feeds_get_source()
  3. 7 mappers/taxonomy.inc \taxonomy_feeds_get_source()

Callback, returns taxonomy from feed node.

1 string reference to 'taxonomy_feeds_get_source'
taxonomy_feeds_parser_sources_alter in mappers/taxonomy.inc
Implements hook_feeds_parser_sources_alter().

File

mappers/taxonomy.inc, line 41
On behalf implementation of Feeds mapping API for taxonomy.module.

Code

function taxonomy_feeds_get_source(FeedsSource $source, FeedsParserResult $result, $key) {
  if ($node = node_load($source->feed_nid)) {
    $terms = taxonomy_feeds_node_get_terms($node);
    $vocabularies = taxonomy_vocabulary_load_multiple(array(), array(
      'machine_name' => str_replace('parent:taxonomy:', '', $key),
    ));
    $vocabulary = array_shift($vocabularies);
    $result = array();
    foreach ($terms as $tid => $term) {
      if ($term->vid == $vocabulary->vid) {
        $result[] = new FeedsTermElement($term);
      }
    }
    return $result;
  }
}