You are here

function node_clone_node_prepopulate in Node clone 8

Clones a node - prepopulate a node editing form

1 call to node_clone_node_prepopulate()
node_clone_node_check in ./node_clone.pages.inc
Menu callback: prompt the user to confirm the operation

File

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

Code

function node_clone_node_prepopulate($original_node) {
  if (isset($original_node->nid)) {
    if (node_clone_is_permitted($original_node->type)) {
      $node = _node_clone_node_prepare($original_node, TRUE);

      // @FIXME
      // drupal_set_title() has been removed. There are now a few ways to set the title
      // dynamically, depending on the situation.
      //
      //
      // @see https://www.drupal.org/node/2067859
      // drupal_set_title($node->title);
      // Let other modules do special fixing up.
      $context = array(
        'method' => 'prepopulate',
        'original_node' => $original_node,
      );
      \Drupal::moduleHandler()
        ->alter('node_clone_node', $node, $context);

      // Make sure the file defining the node form is loaded.
      $form_state = array();
      $form_state['build_info']['args'] = array(
        $node,
      );
      $form_state
        ->loadInclude('node', 'inc', 'node.pages');
      return \Drupal::formBuilder()
        ->buildForm($node->type . '_node_form', $form_state);
    }
  }
}