You are here

function gatsby_entity_delete in Gatsby Live Preview & Incremental Builds 2.0.x

Same name and namespace in other branches
  1. 8 gatsby.module \gatsby_entity_delete()

Implements hook_entity_delete().

File

./gatsby.module, line 185
Contains gatsby.module.

Code

function gatsby_entity_delete(EntityInterface $entity) {

  // Don't run entity_deletes if gatsby_endpoints is enabled.
  $moduleHandler = \Drupal::service('module_handler');
  if ($moduleHandler
    ->moduleExists('gatsby_endpoints')) {
    return;
  }
  $gatsbyPreview = \Drupal::service('gatsby.gatsby_preview');
  if (!$entity instanceof ContentEntityInterface || !$gatsbyPreview
    ->isPreviewEntity($entity)) {
    return;
  }
  if (!$gatsbyPreview
    ->isConfigured()) {
    return;
  }
  $gatsbyPreview
    ->gatsbyPrepareDelete($entity);
  drupal_register_shutdown_function('_gatsby_update');
}