You are here

public function WebformSubmissionStorage::getAnonymousSubmissionIds in Webform 6.x

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

Get anonymous user's submission ids.

Parameters

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

Return value

array| A array of submission ids or NULL if the user us not anonymous or has not saved submissions.

Overrides WebformSubmissionStorageInterface::getAnonymousSubmissionIds

1 call to WebformSubmissionStorage::getAnonymousSubmissionIds()
WebformSubmissionStorage::addQueryConditions in src/WebformSubmissionStorage.php
Add condition to submission query.

File

src/WebformSubmissionStorage.php, line 1506

Class

WebformSubmissionStorage
Defines the webform submission storage.

Namespace

Drupal\webform

Code

public function getAnonymousSubmissionIds(AccountInterface $account) {

  // Make sure the account and current user are identical.
  if ((int) $account
    ->id() !== (int) $this->currentUser
    ->id()) {
    return NULL;
  }
  if (empty($_SESSION['webform_submissions'])) {
    return NULL;
  }

  // Cleanup sids because drafts could have been purged or the webform
  // submission could have been deleted.
  $_SESSION['webform_submissions'] = $this
    ->getQuery()
    ->accessCheck(FALSE)
    ->condition('sid', $_SESSION['webform_submissions'], 'IN')
    ->sort('sid')
    ->execute();
  if (empty($_SESSION['webform_submissions'])) {
    unset($_SESSION['webform_submissions']);
    return NULL;
  }
  return $_SESSION['webform_submissions'];
}