protected function YamlFormSubmissionStorage::getSiblingSubmission in YAML Form 8
2 calls to YamlFormSubmissionStorage::getSiblingSubmission()
- YamlFormSubmissionStorage::getNextSubmission in src/
YamlFormSubmissionStorage.php - Get a form submission's next sibling.
- YamlFormSubmissionStorage::getPreviousSubmission in src/
YamlFormSubmissionStorage.php - Get a form submission's previous sibling.
File
- src/
YamlFormSubmissionStorage.php, line 236
Class
- YamlFormSubmissionStorage
- Defines the form submission storage.
Namespace
Drupal\yamlformCode
protected function getSiblingSubmission(YamlFormSubmissionInterface $yamlform_submission, EntityInterface $entity = NULL, AccountInterface $account = NULL, $direction = 'previous') {
$yamlform = $yamlform_submission
->getYamlForm();
$query = $this
->getQuery();
$query
->condition('yamlform_id', $yamlform
->id());
$query
->range(0, 1);
if ($entity) {
$query
->condition('entity_type', $entity
->getEntityTypeId());
$query
->condition('entity_id', $entity
->id());
}
if ($account) {
$query
->condition('uid', $account
->id());
}
if ($direction == 'previous') {
$query
->condition('sid', $yamlform_submission
->id(), '<');
$query
->sort('sid', 'DESC');
}
else {
$query
->condition('sid', $yamlform_submission
->id(), '>');
$query
->sort('sid', 'ASC');
}
return ($entity_ids = $query
->execute()) ? $this
->load(reset($entity_ids)) : NULL;
}