You are here

public function AutosaveEntityFormDatabaseStorage::hasAutosavedState in Autosave Form 8

Checks if there is any autosaved entity.

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.

string $form_session_id: (optional) The form session id.

Return value

bool TRUE, if any autosaved entities have been found, FALSE otherwise.

Overrides AutosaveEntityFormStorageInterface::hasAutosavedState

1 call to AutosaveEntityFormDatabaseStorage::hasAutosavedState()
AutosaveEntityFormDatabaseStorage::hasAutosavedStateForFormState in src/Storage/AutosaveEntityFormDatabaseStorage.php
Checks if any autosaved state exist for the user based on the form state.

File

src/Storage/AutosaveEntityFormDatabaseStorage.php, line 206

Class

AutosaveEntityFormDatabaseStorage
A database backend for autosave of entity forms.

Namespace

Drupal\autosave_form\Storage

Code

public function hasAutosavedState($form_id, $entity_type_id, $entity_id, $langcode, $uid, $form_session_id = NULL) {
  $query = $this->connection
    ->select(static::AUTOSAVE_ENTITY_FORM_TABLE, 'cefa')
    ->condition('form_id', $form_id);
  if (isset($form_session_id)) {
    $query
      ->condition('form_session_id', $form_session_id);
  }
  $query
    ->condition('entity_type_id', $entity_type_id)
    ->condition('entity_id', $entity_id)
    ->condition('langcode', $langcode)
    ->condition('uid', $uid);
  $count = $query
    ->countQuery()
    ->execute()
    ->fetchField();
  return (bool) $count;
}