You are here

public function GatsbyFastbuildsController::sync in Gatsby Live Preview & Incremental Builds 8

Same name and namespace in other branches
  1. 2.0.x modules/gatsby_fastbuilds/src/Controller/GatsbyFastbuildsController.php \Drupal\gatsby_fastbuilds\Controller\GatsbyFastbuildsController::sync()

Gatsby Fastbuilds sync callback to get incremental content changes.

Return value

Symfony\Component\HttpFoundation\JsonResponse Returns a JsonResponse with all of the content changes since last fetch.

1 string reference to 'GatsbyFastbuildsController::sync'
gatsby_fastbuilds.routing.yml in modules/gatsby_fastbuilds/gatsby_fastbuilds.routing.yml
modules/gatsby_fastbuilds/gatsby_fastbuilds.routing.yml

File

modules/gatsby_fastbuilds/src/Controller/GatsbyFastbuildsController.php, line 52

Class

GatsbyFastbuildsController
Defines a class for serving routes for Gatsby fastbuilds.

Namespace

Drupal\gatsby_fastbuilds\Controller

Code

public function sync($last_fetch) {
  $last_logtime = $this->state
    ->get('gatsby_fastbuilds.last_logtime', 0);
  $sync_data = [
    'status' => -1,
    'timestamp' => time(),
  ];
  if (!empty($last_fetch) && $last_fetch >= $last_logtime) {

    // Get all of the sync entities.
    $sync_data = $this->gatsbyEntityLogger
      ->getSync($last_fetch);
  }
  return new JsonResponse($sync_data);
}