public function SubmissionsCompletedSinceLastSuccess::getResultSet in Webform Scheduled Tasks 8.2
Get an iterator for a set of results matching the conditions of the plugin.
Return value
\Iterator An iterator for all results that match the conditions of the plugin.
Overrides ResultSetPluginInterface::getResultSet
File
- src/
Plugin/ WebformScheduledTasks/ ResultSet/ SubmissionsCompletedSinceLastSuccess.php, line 67
Class
- SubmissionsCompletedSinceLastSuccess
- Get all submissions completed since the last successful run of the task.
Namespace
Drupal\webform_scheduled_tasks\Plugin\WebformScheduledTasks\ResultSetCode
public function getResultSet() {
$this
->initializeQueryDefaults();
// If we have a value for a previously successful run of this scheduled task
// filter results that were completed after the last.
$success_map = $this->state
->get(static::STATE_KEY, []);
if (isset($success_map[$this
->getScheduledTask()
->id()])) {
// Find all submissions that were completed on or after the request time
// of last successful task run.
$this->submissionQuery
->condition('completed', $success_map[$this
->getScheduledTask()
->id()], '>=');
// Restrict the set of submissions to those created before this request
// started. If they were made between the start of the request and time
// taken to execute the query, they will be included in the next scheduled
// run due to the >= condition above.
$this->submissionQuery
->condition('completed', $this->time
->getRequestTime(), '<');
}
return WebformIteratorAggregate::createFromQuery($this->submissionQuery)
->getIterator();
}