You are here

public function WebformSubmissionStorage::deleteAll in Webform 6.x

Same name and namespace in other branches
  1. 8.5 src/WebformSubmissionStorage.php \Drupal\webform\WebformSubmissionStorage::deleteAll()

Delete all webform submissions.

Parameters

\Drupal\webform\WebformInterface|null $webform: (optional) The webform to delete the submissions from.

\Drupal\Core\Entity\EntityInterface|null $source_entity: (optional) A webform submission source entity.

int $limit: (optional) Number of submissions to be deleted.

int $max_sid: (optional) Maximum webform submission id.

Return value

int The number of webform submissions deleted.

Overrides WebformSubmissionStorageInterface::deleteAll

File

src/WebformSubmissionStorage.php, line 256

Class

WebformSubmissionStorage
Defines the webform submission storage.

Namespace

Drupal\webform

Code

public function deleteAll(WebformInterface $webform = NULL, EntityInterface $source_entity = NULL, $limit = NULL, $max_sid = NULL) {
  $query = $this
    ->getQuery();
  $query
    ->accessCheck(FALSE);
  $this
    ->addQueryConditions($query, $webform, $source_entity, NULL);
  if ($max_sid) {
    $query
      ->condition('sid', $max_sid, '<=');
  }
  $query
    ->sort('sid');
  if ($limit) {
    $query
      ->range(0, $limit);
  }
  $entity_ids = $query
    ->execute();
  $entities = $this
    ->loadMultiple($entity_ids);
  $this
    ->delete($entities);
  return count($entities);
}