Act on a node being inserted or updated.
This hook is invoked from $node->save() before the node is saved to the database.
\Drupal\Core\Entity\EntityInterface $node: The node that is being inserted or updated.
Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.
function hook_node_presave(\Drupal\Core\Entity\EntityInterface $node) {
if ($node->nid && $node->moderate) {
// Reset votes when node is updated:
$node->score = 0;
$node->users = '';
$node->votes = 0;
}
}