You are here

public function WebformSubmissionStorage::getSourceEntitiesTotal in Webform 6.x

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

Get total number of source entities.

Parameters

\Drupal\webform\WebformInterface $webform: A webform.

Return value

int Total number of source entities.

Overrides WebformSubmissionStorageInterface::getSourceEntitiesTotal

File

src/WebformSubmissionStorage.php, line 325

Class

WebformSubmissionStorage
Defines the webform submission storage.

Namespace

Drupal\webform

Code

public function getSourceEntitiesTotal(WebformInterface $webform) {
  $query = $this->database
    ->select('webform_submission', 's')
    ->fields('s', [
    'entity_type',
    'entity_id',
  ])
    ->condition('webform_id', $webform
    ->id())
    ->condition('entity_type', '', '<>')
    ->isNotNull('entity_type')
    ->condition('entity_id', '', '<>')
    ->isNotNull('entity_id')
    ->distinct();
  return (int) $query
    ->countQuery()
    ->execute()
    ->fetchField();
}