protected function FeedsNodeProcessor::buildNode in Feeds 7
Same name and namespace in other branches
- 6 plugins/FeedsNodeProcessor.inc \FeedsNodeProcessor::buildNode()
Creates a new node object in memory and returns it.
1 call to FeedsNodeProcessor::buildNode()
- FeedsNodeProcessor::process in plugins/
FeedsNodeProcessor.inc - Implements FeedsProcessor::process().
File
- plugins/
FeedsNodeProcessor.inc, line 332 - Class definition of FeedsNodeProcessor.
Class
- FeedsNodeProcessor
- Creates nodes from feed items.
Code
protected function buildNode($nid, $feed_nid) {
$node = new stdClass();
if (empty($nid)) {
$node->created = REQUEST_TIME;
$populate = TRUE;
}
else {
if ($this->config['update_existing'] == FEEDS_UPDATE_EXISTING) {
$node = node_load($nid, NULL, TRUE);
}
else {
$node->nid = $nid;
$node->vid = db_query("SELECT vid FROM {node} WHERE nid = :nid", array(
':nid' => $nid,
))
->fetchField();
$populate = TRUE;
}
}
if ($populate) {
$node->type = $this->config['content_type'];
$node->changed = REQUEST_TIME;
$node->format = $this->config['input_format'] == FEEDS_NODE_DEFAULT_FORMAT ? filter_fallback_format() : $this->config['input_format'];
$node->feeds_node_item = new stdClass();
$node->feeds_node_item->id = $this->id;
$node->feeds_node_item->imported = REQUEST_TIME;
$node->feeds_node_item->feed_nid = $feed_nid;
$node->feeds_node_item->url = '';
$node->feeds_node_item->guid = '';
}
// Give mappers a hint at what they're operating on.
$node->entity_type = 'node';
// Let other modules populate default values.
node_object_prepare($node);
// Populate properties that are set by node_object_prepare().
$node->log = 'Created/updated by FeedsNodeProcessor';
if ($populate) {
$node->uid = $this->config['author'];
}
return $node;
}