function node_clone_node_save in Node clone 8
Clones a node by directly saving it.
3 calls to node_clone_node_save()
- node_clone_action_node_clone in ./
node_clone.rules.inc - Action callback for cloning a node.
- node_clone_node_check in ./
node_clone.pages.inc - Menu callback: prompt the user to confirm the operation
- node_clone_node_confirm_submit in ./
node_clone.pages.inc - Handle confirm form submission
File
- ./
node_clone.pages.inc, line 213 - Additional functions for Node_Clone module.
Code
function node_clone_node_save($nid, $account = NULL) {
if (is_numeric($nid)) {
$original_node = \Drupal::entityManager()
->getStorage('node')
->load($nid);
if (isset($original_node->nid) && node_clone_is_permitted($original_node->type)) {
$node = _node_clone_node_prepare($original_node, TRUE, $account);
// Let other modules do special fixing up.
$context = array(
'method' => 'save-edit',
'original_node' => $original_node,
);
\Drupal::moduleHandler()
->alter('node_clone_node', $node, $context);
$node
->save();
if (\Drupal::moduleHandler()
->moduleExists('rules')) {
rules_invoke_event('node_clone_node', $node, $original_node);
}
return $node->nid;
}
}
}