You are here

public function GatsbyEntityLogger::getOldestLoggedEntityTimestamp in Gatsby Live Preview & Incremental Builds 8

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

Get the oldest created timestampe for a logged entity.

File

modules/gatsby_fastbuilds/src/GatsbyEntityLogger.php, line 182

Class

GatsbyEntityLogger
Defines a service for logging content entity changes using log entities.

Namespace

Drupal\gatsby_fastbuilds

Code

public function getOldestLoggedEntityTimestamp() {
  $query = $this->entityTypeManager
    ->getStorage('gatsby_log_entity')
    ->getQuery()
    ->accessCheck(FALSE);
  $entity_uuids = $query
    ->sort('created')
    ->range(0, 1)
    ->execute();
  $entities = $this->entityTypeManager
    ->getStorage('gatsby_log_entity')
    ->loadMultiple($entity_uuids);
  if (!empty($entities)) {
    $entity = array_pop($entities);
    return $entity
      ->getCreatedTime();
  }
  return FALSE;
}