Commit 710e096c authored by Damien McKenna's avatar Damien McKenna Committed by Damien McKenna
Browse files

Issue #3262246 by DamienMcKenna: Fastbuilds not working.

parent 23ceb260
Loading
Loading
Loading
Loading
+24 −0
Original line number Diff line number Diff line
@@ -217,6 +217,10 @@ function gatsby_entity_update(EntityInterface $entity) {
  else {
    \Drupal::service('gatsby.logger')->logEntity($entity, 'update', 'build');
  }

  // Notify Gatsby of the update.
  $gatsbyPreview->gatsbyPrepareData($entity);
  drupal_register_shutdown_function('_gatsby_update');
}

/**
@@ -245,6 +249,10 @@ function gatsby_entity_insert(EntityInterface $entity) {

  // Log build insert log.
  \Drupal::service('gatsby.logger')->logEntity($entity, 'insert', 'build');

  // Notify Gatsby of the new content.
  $gatsbyPreview->gatsbyPrepareData($entity);
  drupal_register_shutdown_function('_gatsby_update');
}

/**
@@ -264,6 +272,10 @@ function gatsby_entity_delete(EntityInterface $entity) {
  // Delete from build and preview logs.
  \Drupal::service('gatsby.logger')->logEntity($entity, 'delete', 'build');
  \Drupal::service('gatsby.logger')->logEntity($entity, 'delete', 'preview');

  // Notify Gatsby of the change.
  $gatsbyPreview->gatsbyPrepareData($entity);
  drupal_register_shutdown_function('_gatsby_update');
}

/**
@@ -393,3 +405,15 @@ function gatsby_entity_view(array &$build, EntityInterface $entity, EntityViewDi
    ];
  }
}

/**
 * Triggers the update to the Gatsby Preview and Incremental Builds servers.
 *
 * @see gatsby_entity_insert()
 * @see gatsby_entity_update()
 * @see gatsby_entity_delete()
 */
function _gatsby_update() {
  $gatsbyPreview = \Drupal::service('gatsby.preview');
  $gatsbyPreview->gatsbyUpdate();
}
+1 −1
Original line number Diff line number Diff line
@@ -7,7 +7,7 @@ gatsby.gatsby_admin_form:
    _permission: 'administer gatsby'

gatsby.gatsby_fastbuilds_sync:
  path: '/admin/config/services/gatsby/fastbuilds/sync/{last_fetch}'
  path: '/gatsby-fastbuilds/sync/{last_fetch}'
  defaults:
    _controller: '\Drupal\gatsby\Controller\GatsbyFastbuildsController::sync'
    _title: 'Gatsby Fastbuild Sync'
+8 −2
Original line number Diff line number Diff line
@@ -124,8 +124,14 @@ class GatsbyEntityLogger {
   */
  public function deleteLoggedEntity($uuid, $langcode = 'en', string $type = 'build') {
    $query = $this->entityTypeManager->getStorage('gatsby_log_entity')->getQuery()->accessCheck(FALSE);
    $entity_uuids = $query->condition('entity_uuid', $uuid)->condition('langcode', $langcode)->condition('preview', $type == 'preview')->execute();
    $entities = $this->entityTypeManager->getStorage('gatsby_log_entity')->loadMultiple($entity_uuids);
    $entity_uuids = $query
      ->condition('entity_uuid', $uuid)
      ->condition('langcode', $langcode)
      ->condition('preview', $type == 'preview')
      ->execute();
    $entities = $this->entityTypeManager
      ->getStorage('gatsby_log_entity')
      ->loadMultiple($entity_uuids);

    foreach ($entities as $entity) {
      $entity->delete();