You are here

protected function TabularBaseWebformExporter::buildHeader in Webform 6.x

Same name and namespace in other branches
  1. 8.5 src/Plugin/WebformExporter/TabularBaseWebformExporter.php \Drupal\webform\Plugin\WebformExporter\TabularBaseWebformExporter::buildHeader()

Build export header using webform submission field definitions and webform element columns.

Return value

array An array containing the export header.

3 calls to TabularBaseWebformExporter::buildHeader()
DelimitedWebformExporter::writeHeader in src/Plugin/WebformExporter/DelimitedWebformExporter.php
Write header to export.
TableWebformExporter::writeHeader in src/Plugin/WebformExporter/TableWebformExporter.php
Write header to export.
TestWebformExporter::buildHeader in tests/modules/webform_test_exporter/src/Plugin/WebformExporter/TestWebformExporter.php
Build export header using webform submission field definitions and webform element columns.
1 method overrides TabularBaseWebformExporter::buildHeader()
TestWebformExporter::buildHeader in tests/modules/webform_test_exporter/src/Plugin/WebformExporter/TestWebformExporter.php
Build export header using webform submission field definitions and webform element columns.

File

src/Plugin/WebformExporter/TabularBaseWebformExporter.php, line 56

Class

TabularBaseWebformExporter
Defines abstract tabular exporter used to build CSV files and HTML tables.

Namespace

Drupal\webform\Plugin\WebformExporter

Code

protected function buildHeader() {
  $export_options = $this
    ->getConfiguration();
  $this->fieldDefinitions = $this
    ->getFieldDefinitions();
  $elements = $this
    ->getElements();
  $header = [];
  foreach ($this->fieldDefinitions as $field_definition) {

    // Build a webform element for each field definition so that we can
    // use WebformElement::buildExportHeader(array $element, $export_options).
    $element = [
      '#type' => $field_definition['type'] === 'entity_reference' ? 'entity_autocomplete' : 'element',
      '#admin_title' => '',
      '#title' => (string) $field_definition['title'],
      '#webform_key' => (string) $field_definition['name'],
    ];
    $header = array_merge($header, $this->elementManager
      ->invokeMethod('buildExportHeader', $element, $export_options));
  }

  // Build element columns headers.
  foreach ($elements as $element) {
    $header = array_merge($header, $this->elementManager
      ->invokeMethod('buildExportHeader', $element, $export_options));
  }
  return $header;
}