function NodeTestHooks::nodeInsert
Same name and namespace in other branches
- 11.x core/modules/node/tests/modules/node_test/src/Hook/NodeTestHooks.php \Drupal\node_test\Hook\NodeTestHooks::nodeInsert()
Implements hook_ENTITY_TYPE_insert() for node entities.
This tests saving a node on node insert.
Attributes
#[Hook('node_insert')]
See also
\Drupal\node\Tests\NodeSaveTest::testNodeSaveOnInsert()
File
-
core/
modules/ node/ tests/ modules/ node_test/ src/ Hook/ NodeTestHooks.php, line 178
Class
- NodeTestHooks
- Hook implementations for node_test.
Namespace
Drupal\node_test\HookCode
public function nodeInsert(NodeInterface $node) : void {
// 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.