You are here

function onlyone_node_delete in Allow a content type only once (Only One) 7

Implements hook_node_delete().

File

./onlyone.module, line 275
Allows to define if a content type must have more than one node in the site.

Code

function onlyone_node_delete($node) {

  // Loading the helper functions file.
  module_load_include('inc', 'onlyone', 'onlyone.helpers');

  // As there are not hooks to be fired once a node is deleted from the database
  // a trick similar to the https://www.drupal.org/project/hook_post_action
  // module needs to be implement, similar to the answer described in
  // https://stackoverflow.com/a/46038871/3653989 .
  // Invoking the callback function AFTER the node is deleted.
  drupal_register_shutdown_function('_onlyone_rebuild_menu', $node);
}