You are here

function gatsby_fastbuilds_entity_insert in Gatsby Live Preview & Incremental Builds 8

Same name and namespace in other branches
  1. 2.0.x modules/gatsby_fastbuilds/gatsby_fastbuilds.module \gatsby_fastbuilds_entity_insert()

Implements hook_entity_insert().

File

modules/gatsby_fastbuilds/gatsby_fastbuilds.module, line 44
Contains gatsby_fastbuilds.module.

Code

function gatsby_fastbuilds_entity_insert(EntityInterface $entity) {
  $gatsbyPreview = \Drupal::service('gatsby.gatsby_preview');
  if (!$entity instanceof ContentEntityInterface || !$gatsbyPreview
    ->isPreviewEntity($entity)) {
    return;
  }
  if (\Drupal::config('gatsby_fastbuilds.settings')
    ->get('log_published')) {
    if (!$entity instanceof NodeInterface || !$entity
      ->isPublished()) {
      return;
    }
    \Drupal::service('gatsby.gatsby_logger')
      ->logEntityWithRelationships($entity, 'insert');
  }
  else {
    \Drupal::service('gatsby.gatsby_logger')
      ->logEntity($entity, 'insert');
  }
}