You are here

function gatsby_entity_insert in Gatsby Live Preview & Incremental Builds 8

Same name and namespace in other branches
  1. 2.0.x gatsby.module \gatsby_entity_insert()

Implements hook_entity_insert().

File

./gatsby.module, line 162
Contains gatsby.module.

Code

function gatsby_entity_insert(EntityInterface $entity) {

  // Don't run entity_inserts 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
    ->gatsbyPrepareData($entity, 'insert');
  drupal_register_shutdown_function('_gatsby_update');
}