function node_test_node_insert in Drupal 9
Same name and namespace in other branches
- 8 core/modules/node/tests/modules/node_test/node_test.module \node_test_node_insert()
- 7 modules/node/tests/node_test.module \node_test_node_insert()
Implements hook_ENTITY_TYPE_insert() for node entities.
This tests saving a node on node insert.
See also
\Drupal\node\Tests\NodeSaveTest::testNodeSaveOnInsert()
File
- core/
modules/ node/ tests/ modules/ node_test/ node_test.module, line 171 - A dummy module for testing node related hooks.
Code
function node_test_node_insert(NodeInterface $node) {
// Set the node title to the node ID and save.
if ($node
->getTitle() == 'new') {
$node
->setTitle('Node ' . $node
->id());
$node
->setNewRevision(FALSE);
$node
->save();
}
}