function gatsby_fastbuilds_entity_update in Gatsby Live Preview & Incremental Builds 2.0.x
Same name and namespace in other branches
- 8 modules/gatsby_fastbuilds/gatsby_fastbuilds.module \gatsby_fastbuilds_entity_update()
Implements hook_entity_update().
File
- modules/
gatsby_fastbuilds/ gatsby_fastbuilds.module, line 16 - Contains gatsby_fastbuilds.module.
Code
function gatsby_fastbuilds_entity_update(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) {
return;
}
if ($entity
->isPublished()) {
\Drupal::service('gatsby.gatsby_logger')
->logEntityWithRelationships($entity, 'update');
}
elseif ($entity->original
->isPublished() && $entity
->isDefaultRevision()) {
// If an entity was unpublished then trigger a delete log to remove that
// content from Gatsby.
\Drupal::service('gatsby.gatsby_logger')
->logEntity($entity, 'delete');
}
}
else {
\Drupal::service('gatsby.gatsby_logger')
->logEntity($entity, 'update');
}
}