function node_test_node_insert
Same name in other branches
- 7.x modules/node/tests/node_test.module \node_test_node_insert()
- 9 core/modules/node/tests/modules/node_test/node_test.module \node_test_node_insert()
- 8.9.x core/modules/node/tests/modules/node_test/node_test.module \node_test_node_insert()
- 10 core/modules/node/tests/modules/node_test/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 174
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();
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.