You are here

function node_clone_node_check in Node clone 8

Menu callback: prompt the user to confirm the operation

File

./node_clone.pages.inc, line 96
Additional functions for Node_Clone module.

Code

function node_clone_node_check($node) {
  $method = \Drupal::config('node_clone.settings')
    ->get('node_clone_method');
  switch ($method) {
    case 'save-edit':
      if (\Drupal::config('node_clone.settings')
        ->get('node_clone_nodes_without_confirm')) {
        $new_nid = node_clone_node_save($node->nid);
        $options = array();
        if (!empty($_GET['node-clone-destination'])) {
          $options['query']['destination'] = $_GET['node-clone-destination'];
        }
        drupal_goto('node/' . $new_nid . '/edit', $options);
      }
      else {
        return \Drupal::formBuilder()
          ->getForm('node_clone_node_confirm', $node);
      }
      break;
    case 'prepopulate':
    default:
      return node_clone_node_prepopulate($node);
      break;
  }
}