You are here

public function WebformEntityReferenceTrait::buildExportHeader in Webform 6.x

Same name and namespace in other branches
  1. 8.5 src/Plugin/WebformElement/WebformEntityReferenceTrait.php \Drupal\webform\Plugin\WebformElement\WebformEntityReferenceTrait::buildExportHeader()

File

src/Plugin/WebformElement/WebformEntityReferenceTrait.php, line 285

Class

WebformEntityReferenceTrait
Provides an 'entity_reference' trait.

Namespace

Drupal\webform\Plugin\WebformElement

Code

public function buildExportHeader(array $element, array $options) {
  if (!$this
    ->hasMultipleValues($element)) {
    $default_options = $this
      ->getExportDefaultOptions();
    $header = isset($options['entity_reference_items']) ? $options['entity_reference_items'] : $default_options['entity_reference_items'];
    if ($options['header_format'] === 'label') {
      foreach ($header as $index => $column) {
        switch ($column) {
          case 'id':
            $header[$index] = $this
              ->t('ID');
            break;
          case 'title':
            $header[$index] = $this
              ->t('Title');
            break;
          case 'url':
            $header[$index] = $this
              ->t('URL');
            break;
        }
      }
    }
    return $this
      ->prefixExportHeader($header, $element, $options);
  }
  else {
    return parent::buildExportHeader($element, $options);
  }
}