function hook_comment_predelete

Act before comment deletion.

This hook is invoked from entity_delete_multiple() before field_attach_delete() is called and before the comment is actually removed from the database.

Parameters

Drupal\comment\Comment $comment: The comment object for the comment that is about to be deleted.

See also

hook_comment_delete()

entity_delete_multiple()

Related topics

1 function implements hook_comment_predelete()

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

entity_crud_hook_test_comment_predelete in drupal/core/modules/system/tests/modules/entity_crud_hook_test/entity_crud_hook_test.module
Implements hook_comment_predelete().

File

drupal/core/modules/comment/comment.api.php, line 173
Hooks provided by the Comment module.

Code

function hook_comment_predelete(Drupal\comment\Comment $comment) {

  // Delete a record associated with the comment in a custom table.
  db_delete('example_comment_table')
    ->condition('cid', $comment
    ->id())
    ->execute();
}