You are here

public function AutosaveEntityFormDatabaseStorage::getLastAutosavedStateTimestamp in Autosave Form 8

Retrieves the timestamp of the last autosaved state.

Parameters

$form_id: The form id.

string $entity_type_id: The entity type id of the entity.

mixed $entity_id: The id of the entity to store.

string $langcode: The language code of the original entity.

$uid: The user id.

Return value

int The timestamp of the last autosaved state, or NULL if none has been found.

Overrides AutosaveEntityFormStorageInterface::getLastAutosavedStateTimestamp

File

src/Storage/AutosaveEntityFormDatabaseStorage.php, line 228

Class

AutosaveEntityFormDatabaseStorage
A database backend for autosave of entity forms.

Namespace

Drupal\autosave_form\Storage

Code

public function getLastAutosavedStateTimestamp($form_id, $entity_type_id, $entity_id, $langcode, $uid) {
  $timestamp = $this->connection
    ->select(static::AUTOSAVE_ENTITY_FORM_TABLE, 'cefa')
    ->fields('cefa', [
    'timestamp',
  ])
    ->orderBy('timestamp', 'DESC')
    ->condition('form_id', $form_id)
    ->condition('entity_type_id', $entity_type_id)
    ->condition('entity_id', $entity_id)
    ->condition('langcode', $langcode)
    ->condition('uid', $uid)
    ->execute()
    ->fetchField();
  return is_bool($timestamp) ? NULL : $timestamp;
}