You are here

public function AutosaveEntityFormDatabaseStorage::purgeAutosavedEntitiesStates in Autosave Form 8

Purges all autosaved states matching the conditions.

Calling this method without arguments will empty the whole storage.

Parameters

string $entity_type_id: (optional) The entity type id.

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

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

Overrides AutosaveEntityFormStorageInterface::purgeAutosavedEntitiesStates

File

src/Storage/AutosaveEntityFormDatabaseStorage.php, line 274

Class

AutosaveEntityFormDatabaseStorage
A database backend for autosave of entity forms.

Namespace

Drupal\autosave_form\Storage

Code

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