function hook_delete

Respond to node deletion.

This hook is invoked only on the module that defines the node's content type (use hook_node_delete() to respond to all node deletions).

This hook is invoked from entity_delete_multiple() after the node has been removed from the node table in the database, before hook_node_delete() is invoked, and before field_attach_delete() is called.

Parameters

\Drupal\Core\Entity\EntityInterface $node: The node that is being deleted.

Related topics

57 functions implement hook_delete()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

block_language_delete in drupal/core/modules/block/block.module
Implements hook_language_delete().
block_menu_delete in drupal/core/modules/block/block.module
Implements hook_menu_delete().
block_user_role_delete in drupal/core/modules/block/block.module
Implements hook_user_role_delete().
comment_confirm_delete in drupal/core/modules/comment/comment.admin.inc
Form constructor for the confirmation form for comment deletion.
comment_node_type_delete in drupal/core/modules/comment/comment.module
Implements hook_node_type_delete().

... See full list

File

drupal/core/modules/node/node.api.php, line 1046
Hooks provided by the Node module.

Code

function hook_delete(\Drupal\Core\Entity\EntityInterface $node) {
  db_delete('mytable')
    ->condition('nid', $node->nid)
    ->execute();
}