You are here

function _create_node in Responsive and off-canvas menu 4.1.x

Same name and namespace in other branches
  1. 4.4.x tests/modules/responsive_menu_test/responsive_menu_test.install \_create_node()
  2. 4.3.x tests/modules/responsive_menu_test/responsive_menu_test.install \_create_node()

Helper function to create test nodes.

@noinspection PhpFullyQualifiedNameUsageInspection

Parameters

array $node_data: An array of data for the new node.

Throws

\Drupal\Core\Entity\EntityStorageException

1 call to _create_node()
responsive_menu_test_install in tests/modules/responsive_menu_test/responsive_menu_test.install
Implements hook_install().

File

tests/modules/responsive_menu_test/responsive_menu_test.install, line 120
Install file for responsive_menu_test module.

Code

function _create_node(array $node_data) {
  $node = Node::create([
    'type' => 'page',
    'title' => $node_data['title'],
    'body' => [
      'value' => $node_data['body'],
      'format' => 'basic_html',
    ],
  ]);
  $node
    ->save();
}