You are here

public function AutosaveEntityFormDatabaseStorage::hasAutosavedStateForFormState in Autosave Form 8

Checks if any autosaved state exist for the user based on the form state.

Parameters

\Drupal\Core\Form\FormStateInterface $form_state: The form state.

$uid: The user id.

Return value

bool TRUE if the storage contains an autosaved state for the user id based on the form state, FALSE otherwise.

Overrides AutosaveEntityFormStorageInterface::hasAutosavedStateForFormState

File

src/Storage/AutosaveEntityFormDatabaseStorage.php, line 195

Class

AutosaveEntityFormDatabaseStorage
A database backend for autosave of entity forms.

Namespace

Drupal\autosave_form\Storage

Code

public function hasAutosavedStateForFormState(FormStateInterface $form_state, $uid) {
  $result = FALSE;
  if (($form_object = $form_state
    ->getFormObject()) && $form_object instanceof EntityFormInterface && ($entity = $form_object
    ->getEntity()) && !$entity
    ->isNew()) {
    $result = $this
      ->hasAutosavedState($form_object
      ->getFormId(), $entity
      ->getEntityTypeId(), $entity
      ->id(), $entity
      ->language()
      ->getId(), $uid, $form_state
      ->get('autosave_form_session_id'));
  }
  return $result;
}