You are here

public function MultiNodeAddController::formPage in Multi Node Add 8

Content of the iframe with the modified node form.

1 string reference to 'MultiNodeAddController::formPage'
multi_node_add.routing.yml in ./multi_node_add.routing.yml
multi_node_add.routing.yml

File

src/Controller/MultiNodeAddController.php, line 41

Class

MultiNodeAddController
Controller for Multi Node Add.

Namespace

Drupal\multi_node_add\Controller

Code

public function formPage(NodeTypeInterface $node_type = NULL) {
  $account = $this
    ->currentUser();
  $langcode = $this
    ->moduleHandler()
    ->invoke('language', 'get_default_langcode', [
    'node',
    $node_type
      ->getOriginalId(),
  ]);
  $node = $this
    ->entityTypeManager()
    ->getStorage('node')
    ->create([
    'uid' => $account
      ->id(),
    'name' => $account
      ->getAccountName() ?: '',
    'type' => $node_type
      ->getOriginalId(),
    'langcode' => $langcode ? $langcode : $this
      ->languageManager()
      ->getCurrentLanguage()
      ->getId(),
  ]);
  $form = $this
    ->entityFormBuilder()
    ->getForm($node, 'default', [
    'multi_node_add_hijacked' => TRUE,
  ]);
  return $form;
}