You are here

public function WebformSubmissionExporter::getBatchLimit in Webform 6.x

Same name and namespace in other branches
  1. 8.5 src/WebformSubmissionExporter.php \Drupal\webform\WebformSubmissionExporter::getBatchLimit()

Get the number of submissions to be exported with each batch.

Return value

int Number of submissions to be exported with each batch.

Overrides WebformSubmissionExporterInterface::getBatchLimit

2 calls to WebformSubmissionExporter::getBatchLimit()
WebformSubmissionExporter::isBatch in src/WebformSubmissionExporter.php
Determine if export needs to use batch processing.
WebformSubmissionExporter::requiresBatch in src/WebformSubmissionExporter.php
Determine if webform submissions must be exported using batch processing.

File

src/WebformSubmissionExporter.php, line 1080

Class

WebformSubmissionExporter
Webform submission exporter.

Namespace

Drupal\webform

Code

public function getBatchLimit() {
  $batch_limit = $this
    ->getExporter()
    ->getBatchLimit();
  $export_options = $this
    ->getExportOptions();

  // For file and attachment exports set the batch limit to 100.
  if (($export_options['files'] || $export_options['attachments']) && $batch_limit > 100) {
    $batch_limit = 100;
  }

  // Allow attachment elements to lower the batch limit.
  // @see \Drupal\webform_entity_print_attachment\Plugin\WebformElement\WebformEntityPrintAttachment::getAttachmentsExportBatchLimit
  if ($export_options['attachments']) {
    $attachment_elements = $this
      ->getWebformExportAttachmentElements();
    foreach ($attachment_elements as $attachment_element) {

      /** @var \Drupal\webform\Plugin\WebformElementAttachmentInterface $attachment_element_plugin */
      $attachment_element_plugin = $this->elementManager
        ->getElementInstance($attachment_element);
      $attachment_batch_limit = $attachment_element_plugin
        ->getExportAttachmentsBatchLimit();
      if ($attachment_batch_limit && $attachment_batch_limit < $batch_limit) {
        $batch_limit = $attachment_batch_limit;
      }
    }
  }
  return $batch_limit;
}