public function FeedsParser::getSourceElement in Feeds 8.2
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
FeedsCSVParser::getSourceElement()
Related topics
1 call to FeedsParser::getSourceElement()
- FeedsCSVParser::getSourceElement in lib/
Drupal/ feeds/ Plugin/ feeds/ parser/ FeedsCSVParser.php - Override parent::getSourceElement() to use only lower keys.
1 method overrides FeedsParser::getSourceElement()
- FeedsCSVParser::getSourceElement in lib/
Drupal/ feeds/ Plugin/ feeds/ parser/ FeedsCSVParser.php - Override parent::getSourceElement() to use only lower keys.
File
- lib/
Drupal/ feeds/ Plugin/ FeedsParser.php, line 107 - Contains FeedsParser and related classes.
Class
- FeedsParser
- Abstract class, defines interface for parsers.
Namespace
Drupal\feeds\PluginCode
public function getSourceElement(FeedsSource $source, FeedsParserResult $result, $element_key) {
switch ($element_key) {
case 'parent:uid':
if ($source->feed_nid && ($node = node_load($source->feed_nid))) {
return $node->uid;
}
break;
case 'parent:nid':
return $source->feed_nid;
}
$item = $result
->currentItem();
return isset($item[$element_key]) ? $item[$element_key] : '';
}