You are here

public function FeedsParser::getSourceElement in Feeds 6

Same name and namespace in other branches
  1. 7.2 plugins/FeedsParser.inc \FeedsParser::getSourceElement()
  2. 7 plugins/FeedsParser.inc \FeedsParser::getSourceElement()

Get an element identified by $element_key of the given item. The element key corresponds to the values in the array returned by FeedsParser::getMappingSources().

This method is invoked from FeedsProcessor::map() when a concrete item is processed.

Parameters

$batch: FeedsImportBatch object containing the sources to be mapped from.

$element_key: The key identifying the element that should be retrieved from $source

Return value

The source element from $item identified by $element_key.

See also

FeedsProcessor::map()

FeedsCSVParser::getSourceElement().

Related topics

1 call to FeedsParser::getSourceElement()
FeedsCSVParser::getSourceElement in plugins/FeedsCSVParser.inc
Override parent::getSourceElement() to use only lower keys.
1 method overrides FeedsParser::getSourceElement()
FeedsCSVParser::getSourceElement in plugins/FeedsCSVParser.inc
Override parent::getSourceElement() to use only lower keys.

File

plugins/FeedsParser.inc, line 87

Class

FeedsParser
Abstract class, defines interface for parsers.

Code

public function getSourceElement(FeedsImportBatch $batch, $element_key) {
  switch ($element_key) {
    case 'parent:uid':
      if ($batch->feed_nid && ($node = node_load($batch->feed_nid))) {
        return $node->uid;
      }
      break;
    case 'parent:nid':
      return $batch->feed_nid;
  }
  $item = $batch
    ->currentItem();
  return isset($item[$element_key]) ? $item[$element_key] : '';
}