You are here

protected function FeedsFeedNodeProcessor::map in Feeds 7

Same name and namespace in other branches
  1. 6 plugins/FeedsFeedNodeProcessor.inc \FeedsFeedNodeProcessor::map()

Execute mapping on an item.

Overrides FeedsProcessor::map

1 call to FeedsFeedNodeProcessor::map()
FeedsFeedNodeProcessor::process in plugins/FeedsFeedNodeProcessor.inc
Implements FeedsProcessor::process().

File

plugins/FeedsFeedNodeProcessor.inc, line 70
Class definition of FeedsFeedNodeProcessor.

Class

FeedsFeedNodeProcessor
Creates *feed* nodes from feed items. The difference to FeedsNodeProcessor is that this plugin only creates nodes that are feed nodes themselves.

Code

protected function map(FeedsImportBatch $batch) {

  // Prepare node object.
  static $included;
  if (!$included) {
    module_load_include('inc', 'node', 'node.pages');
    $included = TRUE;
  }
  $target_node = new stdClass();
  $target_node->type = $this->config['content_type'];
  $target_node->feeds = array();

  // Suppress auto import, we may be creating many feeds
  $target_node->feeds['suppress_import'] = TRUE;
  node_object_prepare($target_node);

  /*
  Assign an aggregated node always to current user.
  @todo This won't work in all cases as the assumption here is that
  import is happening one off when user is logged in. Assumption breaks if
  feed node processor is being used for aggregation on cron time and a
  specific user should still be the owner of the imported feed nodes.
  */
  global $user;
  $target_node->uid = $user->uid;

  // Have parent class do the iterating.
  return parent::map($batch, $target_node);
}