You are here

public function WebformSubmissionStorage::getMaxSubmissionId in Webform 6.x

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

Get the maximum sid.

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.

Return value

int Total number of submissions.

Overrides WebformSubmissionStorageInterface::getMaxSubmissionId

File

src/WebformSubmissionStorage.php, line 293

Class

WebformSubmissionStorage
Defines the webform submission storage.

Namespace

Drupal\webform

Code

public function getMaxSubmissionId(WebformInterface $webform = NULL, EntityInterface $source_entity = NULL, AccountInterface $account = NULL) {
  $query = $this
    ->getQuery();
  $query
    ->accessCheck(FALSE);
  $this
    ->addQueryConditions($query, $webform, $source_entity, $account);
  $query
    ->sort('sid', 'DESC');
  $query
    ->range(0, 1);
  $result = $query
    ->execute();
  return reset($result);
}