You are here

public function FeedsNodeProcessor::setTargetElement in Feeds 6

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

Override setTargetElement to operate on a target item that is a node.

Overrides FeedsProcessor::setTargetElement

File

plugins/FeedsNodeProcessor.inc, line 263
Class definition of FeedsNodeProcessor.

Class

FeedsNodeProcessor
Creates nodes from feed items.

Code

public function setTargetElement(&$target_node, $target_element, $value) {
  switch ($target_element) {
    case 'url':
    case 'guid':
      $target_node->feeds_node_item->{$target_element} = $value;
      break;
    case 'body':
      $target_node->teaser = node_teaser($value);
      $target_node->body = $value;
      break;
    case 'title':
    case 'status':
    case 'created':
    case 'nid':
    case 'uid':
      $target_node->{$target_element} = $value;
      break;
    case 'user_name':
      if ($user = user_load(array(
        'name' => $value,
      ))) {
        $target_node->uid = $user->uid;
      }
      break;
    case 'user_mail':
      if ($user = user_load(array(
        'mail' => $value,
      ))) {
        $target_node->uid = $user->uid;
      }
      break;
  }
}