Create a Node in Drupal 8

Submitted by timmillwood on Mon, 27/02/2017 - 14:41

This is especially useful in kernel tests.

$node = Node::create([
  'type' => 'article',
  'title' => 'Example Node'
]);
$node->save()

Add new comment