function node_test_node_presave in Drupal 9
Same name and namespace in other branches
- 8 core/modules/node/tests/modules/node_test/node_test.module \node_test_node_presave()
- 7 modules/node/tests/node_test.module \node_test_node_presave()
Implements hook_ENTITY_TYPE_presave() for node entities.
File
- core/
modules/ node/ tests/ modules/ node_test/ node_test.module, line 126 - A dummy module for testing node related hooks.
Code
function node_test_node_presave(NodeInterface $node) {
if ($node
->getTitle() == 'testing_node_presave') {
// Sun, 19 Nov 1978 05:00:00 GMT
$node
->setCreatedTime(280299600);
// Drupal 1.0 release.
$node->changed = 979534800;
}
// Determine changes.
if (!empty($node->original) && $node->original
->getTitle() == 'test_changes') {
if ($node->original
->getTitle() != $node
->getTitle()) {
$node->title->value .= '_presave';
}
}
}