Loading gatsby.module +24 −0 Original line number Diff line number Diff line Loading @@ -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'); } /** Loading Loading @@ -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'); } /** Loading @@ -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'); } /** Loading Loading @@ -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(); } gatsby.routing.yml +1 −1 Original line number Diff line number Diff line Loading @@ -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' Loading src/GatsbyEntityLogger.php +8 −2 Original line number Diff line number Diff line Loading @@ -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(); Loading Loading
gatsby.module +24 −0 Original line number Diff line number Diff line Loading @@ -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'); } /** Loading Loading @@ -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'); } /** Loading @@ -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'); } /** Loading Loading @@ -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(); }
gatsby.routing.yml +1 −1 Original line number Diff line number Diff line Loading @@ -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' Loading
src/GatsbyEntityLogger.php +8 −2 Original line number Diff line number Diff line Loading @@ -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(); Loading