public function WebformSubmissionsDeleteFormBase::batchProcess in Webform 6.x
Same name and namespace in other branches
- 8.5 src/Form/WebformSubmissionsDeleteFormBase.php \Drupal\webform\Form\WebformSubmissionsDeleteFormBase::batchProcess()
Batch API callback; Delete submissions.
Parameters
\Drupal\webform\WebformInterface|null $webform: The webform.
\Drupal\Core\Entity\EntityInterface|null $entity: The webform's source entity.
int $max_sid: The max submission ID to be delete.
mixed|array $context: The batch current context.
File
- src/
Form/ WebformSubmissionsDeleteFormBase.php, line 174
Class
- WebformSubmissionsDeleteFormBase
- Base webform for deleting webform submission.
Namespace
Drupal\webform\FormCode
public function batchProcess(WebformInterface $webform = NULL, EntityInterface $entity = NULL, $max_sid, &$context) {
if (empty($context['sandbox'])) {
$context['sandbox']['progress'] = 0;
$context['sandbox']['max'] = $this
->getSubmissionStorage()
->getTotal($webform, $entity, NULL, [
'in_draft' => NULL,
]);
$context['results']['webform'] = $webform;
$context['results']['entity'] = $entity;
}
// Track progress.
$context['sandbox']['progress'] += $this
->getSubmissionStorage()
->deleteAll($webform, $entity, $this
->getBatchLimit(), $max_sid);
$context['message'] = $this
->t('Deleting @count of @total submissions…', [
'@count' => $context['sandbox']['progress'],
'@total' => $context['sandbox']['max'],
]);
// Track finished.
if ($context['sandbox']['progress'] !== $context['sandbox']['max']) {
$context['finished'] = $context['sandbox']['progress'] / $context['sandbox']['max'];
}
}