drupal 8 take action when node deleted
- drupal 8 take action when node deleted
- D8 replacement for hook_node_delete
Add comment here with Drupal 8 equivalent: https://api.drupal.org/api/drupal/modules%21node%21node.api.php/function/hook_node_delete/7.x
It still exists in Drupal 8 and 9, as a specific case of hook_ENTITY_TYPE_delete
:
… of course, we’re using a soft-delete (trashbin) workflow, made somewhat elegant by the Workflow Buttons module. So acting on actual delete isn’t going to do what we need.
Instead, we need to do stuff when the the workflow state changes.
- drupal 8 act on node when content moderation state changes
- d8 react on entity workflow state change
In Drupal 8 and Drupal 9, this should be an event. It isn’t yet:
Dispatch events for changing content moderation states [#2873287] | Drupal.org
Until then, we have to dive into the guts of the moderation state a bit on a nodeapi hook. Fortunately as linked from that issue, the Content Moderation Notifications module gives a good example of the code needed to do that:
…
Anyhow what i was trying to do with that…
- drupal 8 search API update index immediately when item deleted
Remove specific node from index [#2824812] | Drupal.org
Thanks to the work in this issue - Index items only at end of page request [#2922525] | Drupal.org - see also this change record - “Index items immediately” will now only index items at the end of the page request | Drupal.org - the perceived performance should still be good.