You are here

protected function YamlFormSubmissionStorage::getTerminusSubmission in YAML Form 8

2 calls to YamlFormSubmissionStorage::getTerminusSubmission()
YamlFormSubmissionStorage::getFirstSubmission in src/YamlFormSubmissionStorage.php
Get a form's first submission.
YamlFormSubmissionStorage::getLastSubmission in src/YamlFormSubmissionStorage.php
Get a form's last submission.

File

src/YamlFormSubmissionStorage.php, line 217

Class

YamlFormSubmissionStorage
Defines the form submission storage.

Namespace

Drupal\yamlform

Code

protected function getTerminusSubmission(YamlFormInterface $yamlform, EntityInterface $source_entity = NULL, AccountInterface $account = NULL, $sort = 'DESC') {
  $query = $this
    ->getQuery();
  $query
    ->condition('yamlform_id', $yamlform
    ->id());
  $query
    ->condition('in_draft', FALSE);
  $query
    ->range(0, 1);
  if ($source_entity) {
    $query
      ->condition('entity_type', $source_entity
      ->getEntityTypeId());
    $query
      ->condition('entity_id', $source_entity
      ->id());
  }
  if ($account) {
    $query
      ->condition('uid', $account
      ->id());
  }
  $query
    ->sort('sid', $sort);
  return ($entity_ids = $query
    ->execute()) ? $this
    ->load(reset($entity_ids)) : NULL;
}