You are here

function search_by_page_attach_node_delete in Search by Page 8

Implements hook_node_delete().

When a node is deleted, remove its attached files from the search index.

File

search_by_page_attach/search_by_page_attach.module, line 577
Module file for Search by Page Attachments, a sub-module for Search by Page.

Code

function search_by_page_attach_node_delete($node) {

  // Find the search_by_page_attach IDs in our database associated with this node ID.
  $res = \Drupal::database()
    ->query("SELECT sbpaid FROM {sbpa_attachments} WHERE objtype = 'node' AND objid = :nid", array(
    ':nid' => $node->nid,
  ))
    ->fetchCol();
  foreach ($res as $id) {
    search_by_page_force_remove('search_by_page_attach', $id);
  }
}