I want to save some details before saving the node, and I tried with hook_node_presave()
.
function hook_node_presave(Drupal Core Entity EntityInterface $node) {
if ($node->id() && $node->moderate) {
// Reset votes when node is updated:
$node->score = 0;
$node->users = '';
$node->votes = 0;
}
}
Then with hook_entity_presave()
.
function hook_entity_presave(Drupal Core Entity EntityInterface $entity) {
$entity->changed = REQUEST_TIME;
}
Both hooks don't work. Why?