public static function Nodes::createNewNode in Hook Update Deploy Tools 7
Create a node from the imported object.
Parameters
object $node: The node object from the import file.
Return value
object The resulting node from node_save, broken free of reference to $node.
1 call to Nodes::createNewNode()
- Nodes::processOne in src/
Nodes.php - Validated Updates/Imports one page from the contents of an import file.
File
- src/
Nodes.php, line 319
Class
- Nodes
- Public method for changing nodes programatically.
Namespace
HookUpdateDeployToolsCode
public static function createNewNode($node) {
// @TODO Need to add handling for field collections.
// @TODO Need to add handling for entity reference.
$saved_node = clone $node;
unset($saved_node->nid);
unset($saved_node->workbench_moderation);
// Map imported states to new moderation states.
if (!empty($node->workbench_moderation)) {
$saved_node->workbench_moderation_state_current = $node->workbench_moderation['current']->state;
$saved_node->workbench_moderation_state_new = $node->workbench_moderation['current']->state;
}
$saved_node->revision = 1;
$saved_node->is_new = TRUE;
unset($saved_node->vid);
$log = !empty($saved_node->log) ? $saved_node->log : '';
$message = t("Created from import file by hook_update_deploy_tools Node import.");
// Concatenate the created record to the imported log message.
$saved_node->log = "{$message}\n {$log}";
node_save($saved_node);
return $saved_node;
}