You are here

public function WebformSubmissionExporter::getDefaultExportOptions in Webform 6.x

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

Get default export options.

Return value

array Default export options.

Overrides WebformSubmissionExporterInterface::getDefaultExportOptions

3 calls to WebformSubmissionExporter::getDefaultExportOptions()
WebformSubmissionExporter::buildExportOptionsForm in src/WebformSubmissionExporter.php
Build export options webform.
WebformSubmissionExporter::getValuesFromInput in src/WebformSubmissionExporter.php
Get the values from the webform's user input or webform state values.
WebformSubmissionExporter::setExporter in src/WebformSubmissionExporter.php
Set results exporter.

File

src/WebformSubmissionExporter.php, line 245

Class

WebformSubmissionExporter
Webform submission exporter.

Namespace

Drupal\webform

Code

public function getDefaultExportOptions() {
  if (isset($this->defaultOptions)) {
    return $this->defaultOptions;
  }
  $this->defaultOptions = [
    'exporter' => 'delimited',
    'delimiter' => ',',
    'multiple_delimiter' => ';',
    'excel' => FALSE,
    'file_name' => 'submission-[webform_submission:serial]',
    'archive_type' => 'tar',
    'header_format' => 'label',
    'header_prefix' => TRUE,
    'header_prefix_label_delimiter' => ': ',
    'header_prefix_key_delimiter' => '__',
    'excluded_columns' => [
      'uuid' => 'uuid',
      'token' => 'token',
      'webform_id' => 'webform_id',
    ],
    'entity_type' => '',
    'entity_id' => '',
    'range_type' => 'all',
    'range_latest' => '',
    'range_start' => '',
    'range_end' => '',
    'uid' => '',
    'order' => 'asc',
    'state' => 'all',
    'locked' => '',
    'sticky' => '',
    'download' => TRUE,
    'files' => FALSE,
    'attachments' => FALSE,
  ];

  // Append webform exporter default options.
  $exporter_plugins = $this->exporterManager
    ->getInstances();
  foreach ($exporter_plugins as $element_type => $element_plugin) {
    $this->defaultOptions = $element_plugin
      ->defaultConfiguration() + $this->defaultOptions;
  }

  // Append webform element default options.
  $element_types = $this
    ->getWebformElementTypes();
  $element_plugins = $this->elementManager
    ->getInstances();
  foreach ($element_plugins as $element_type => $element_plugin) {
    if (empty($element_types) || isset($element_types[$element_type])) {
      $this->defaultOptions += $element_plugin
        ->getExportDefaultOptions();
    }
  }
  return $this->defaultOptions;
}