function NodeTestHooks::nodePresave
Implements hook_ENTITY_TYPE_presave() for node entities.
File
-
core/
modules/ node/ tests/ modules/ node_test/ src/ Hook/ NodeTestHooks.php, line 135
Class
- NodeTestHooks
- Hook implementations for node_test.
Namespace
Drupal\node_test\HookCode
public function nodePresave(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';
}
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.