You are here

public function AutosaveEntityFormDatabaseStorage::purgeAutosavedEntityState in Autosave Form 8

Purges all autosaved states for the given entity.

Parameters

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

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

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

$form_id: (optional) The form id.

string $langcode: (optional) The language code, for which to restrict the purge.

$uid: (optional) The user id, for which to restrict the purge.

Overrides AutosaveEntityFormStorageInterface::purgeAutosavedEntityState

File

src/Storage/AutosaveEntityFormDatabaseStorage.php, line 246

Class

AutosaveEntityFormDatabaseStorage
A database backend for autosave of entity forms.

Namespace

Drupal\autosave_form\Storage

Code

public function purgeAutosavedEntityState($entity_type_id, $entity_id, $form_session_id = NULL, $form_id = NULL, $langcode = NULL, $uid = NULL) {
  $query = $this->connection
    ->delete(static::AUTOSAVE_ENTITY_FORM_TABLE);
  if (isset($form_session_id)) {
    $query
      ->condition('form_session_id', $form_session_id);
  }
  if (isset($form_id)) {
    $query
      ->condition('form_id', $form_id);
  }
  $query
    ->condition('entity_type_id', $entity_type_id)
    ->condition('entity_id', $entity_id);
  if (isset($langcode)) {
    $query
      ->condition('langcode', $langcode);
  }
  if (isset($uid)) {
    $query
      ->condition('uid', $uid);
  }
  $query
    ->execute();
}