public function WebformSubmissionsDeleteFormBase::batchProcess in Webform 8.5
Same name and namespace in other branches
- 6.x 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 194
Class
- WebformSubmissionsDeleteFormBase
- Base webform for deleting webform submission.
Namespace
Drupal\webform\FormCode
public function batchProcess(WebformInterface $webform = NULL, EntityInterface $entity = NULL, $max_sid, &$context) {
// ISSUE:
// $this->submissionStorage is not being setup via
// WebformSubmissionsDeleteFormBase::__construct.
//
// WORKAROUND:
// Reset it for each batch process.
$this->submissionStorage = \Drupal::entityTypeManager()
->getStorage('webform_submission');
if (empty($context['sandbox'])) {
$context['sandbox']['progress'] = 0;
$context['sandbox']['max'] = $this->submissionStorage
->getTotal($webform, $entity, NULL, [
'in_draft' => NULL,
]);
$context['results']['webform'] = $webform;
$context['results']['entity'] = $entity;
}
// Track progress.
$context['sandbox']['progress'] += $this->submissionStorage
->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'];
}
}