You are here

public function RelationFeedsProcessor::setTargetElement in Relation 7

File

relation_feeds/RelationFeedsProcessor.inc, line 254
Class definition of RelationFeedsProcessor.

Class

RelationFeedsProcessor
Creates relations from feed items.

Code

public function setTargetElement(FeedsSource $source, $target_relation, $target_element, $value) {
  switch ($target_element) {
    case 'created':
      $target_relation->created = feeds_to_unixtime($value, REQUEST_TIME);
      break;
    case 'feeds_source':

      // Get the class of the feed relation importer's fetcher and set the source
      // property. See feeds_relation_update() how $relation->feeds gets stored.
      if ($id = feeds_get_importer_id($this->config['bundle'])) {
        $class = get_class(feeds_importer($id)->fetcher);
        $target_relation->feeds[$class]['source'] = $value;

        // This effectively suppresses 'import on submission' feature.
        // See feeds_relation_insert().
        $target_relation->feeds['suppress_import'] = TRUE;
      }
      break;
    default:
      parent::setTargetElement($source, $target_relation, $target_element, $value);
      break;
  }
}