You are here

public function WebformSubmissionStorage::getTotal in Webform 6.x

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

Get the total number of submissions.

Parameters

\Drupal\webform\WebformInterface|null $webform: (optional) A webform. If set the total number of submissions for the Webform will be returned.

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

\Drupal\Core\Session\AccountInterface|null $account: (optional) A user account.

array $options: Options/conditions include:

  • in_draft (boolean): NULL will return all saved submissions and drafts. Defaults to FALSE.
  • interval (int): Limit total within an seconds interval.

Return value

int Total number of submissions.

Overrides WebformSubmissionStorageInterface::getTotal

File

src/WebformSubmissionStorage.php, line 277

Class

WebformSubmissionStorage
Defines the webform submission storage.

Namespace

Drupal\webform

Code

public function getTotal(WebformInterface $webform = NULL, EntityInterface $source_entity = NULL, AccountInterface $account = NULL, array $options = []) {

  // Default total to only look at completed submissions.
  $options += [
    'in_draft' => FALSE,
  ];
  $query = $this
    ->getQuery();
  $query
    ->accessCheck(FALSE);
  $this
    ->addQueryConditions($query, $webform, $source_entity, $account, $options);
  $query
    ->count();
  return $query
    ->execute();
}