public function GatsbyEntityLogger::getSync in Gatsby Live Preview & Incremental Builds 8
Same name and namespace in other branches
- 2.0.x modules/gatsby_fastbuilds/src/GatsbyEntityLogger.php \Drupal\gatsby_fastbuilds\GatsbyEntityLogger::getSync()
Gets log entities for a sync based on last fetched timestamp.
Parameters
int $last_fetch: The time the sync was last fetched.
Return value
array The JSON data for the entities to sync.
File
- modules/
gatsby_fastbuilds/ src/ GatsbyEntityLogger.php, line 205
Class
- GatsbyEntityLogger
- Defines a service for logging content entity changes using log entities.
Namespace
Drupal\gatsby_fastbuildsCode
public function getSync($last_fetch) {
$query = $this->entityTypeManager
->getStorage('gatsby_log_entity')
->getQuery()
->accessCheck(FALSE);
$entity_uuids = $query
->condition('created', $last_fetch, '>')
->sort('created')
->execute();
$entities = $this->entityTypeManager
->getStorage('gatsby_log_entity')
->loadMultiple($entity_uuids);
$sync_data = [
'timestamp' => time(),
'entities' => [],
];
foreach ($entities as $entity) {
if ($entity instanceof GatsbyLogEntityInterface) {
$sync_data['timestamp'] = $entity
->getCreatedTime();
$sync_data['entities'][] = json_decode($entity
->get('json')->value);
}
}
return $sync_data;
}