I would like to perform the following mass action via VBO: send a mail to author of a node.
This mail is configured and sent in a hook_entity_update function.
The beginning of the function is the following :
if (is_null($entity)) return;
if (!isset($entity)) return;
$nid = \Drupal::routeMatch()->getRawParameter('node');
if ($nid) {
$type = $node->bundle();
if ($type != 'membre') {
return;
}
}
else if ($nid == null) {
return;
}
...
$mailManager->mail($module, $key, $to_trsf, $langcode, $params, NULL, $send);
test 1: If I update manually the node, the mail is sent.
test 2: If I update the node through a VBO, the mail is not sent because the nid is null, so the "return" statement is done.
Is there a possibility to retrieve the nid of a node when the hook is fired throught a VBO action?