You are here

protected function FeedsProcessor::uniqueTargets in Feeds 7

Same name and namespace in other branches
  1. 6 plugins/FeedsProcessor.inc \FeedsProcessor::uniqueTargets()
  2. 7.2 plugins/FeedsProcessor.inc \FeedsProcessor::uniqueTargets()

Utility function that iterates over a target array and retrieves all sources that are unique.

Parameters

$batch: A FeedsImportBatch.

Return value

An array where the keys are target field names and the values are the elements from the source item mapped to these targets.

4 calls to FeedsProcessor::uniqueTargets()
FeedsFeedNodeProcessor::existingItemId in plugins/FeedsFeedNodeProcessor.inc
Get nid of an existing feed item node if available.
FeedsNodeProcessor::existingItemId in plugins/FeedsNodeProcessor.inc
Get nid of an existing feed item node if available.
FeedsTermProcessor::existingItemId in plugins/FeedsTermProcessor.inc
Get id of an existing feed item term if available.
FeedsUserProcessor::existingItemId in plugins/FeedsUserProcessor.inc
Get id of an existing feed item term if available.

File

plugins/FeedsProcessor.inc, line 218

Class

FeedsProcessor
Abstract class, defines interface for processors.

Code

protected function uniqueTargets(FeedsImportBatch $batch) {
  $parser = feeds_importer($this->id)->parser;
  $targets = array();
  foreach ($this->config['mappings'] as $mapping) {
    if ($mapping['unique']) {

      // Invoke the parser's getSourceElement to retrieve the value for this
      // mapping's source.
      $targets[$mapping['target']] = $parser
        ->getSourceElement($batch, $mapping['source']);
    }
  }
  return $targets;
}