You are here

protected function WebformSubmissionExporter::getWebformElementTypes in Webform 6.x

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

Get element types from a webform.

Return value

array An array of element types from a webform.

2 calls to WebformSubmissionExporter::getWebformElementTypes()
WebformSubmissionExporter::buildExportOptionsForm in src/WebformSubmissionExporter.php
Build export options webform.
WebformSubmissionExporter::getDefaultExportOptions in src/WebformSubmissionExporter.php
Get default export options.

File

src/WebformSubmissionExporter.php, line 1007

Class

WebformSubmissionExporter
Webform submission exporter.

Namespace

Drupal\webform

Code

protected function getWebformElementTypes() {
  if (isset($this->elementTypes)) {
    return $this->elementTypes;
  }

  // If the webform is not set which only occurs on the admin settings webform,
  // return an empty array.
  if (!isset($this->webform)) {
    return [];
  }
  $this->elementTypes = [];
  $elements = $this->webform
    ->getElementsDecodedAndFlattened();

  // Always include 'entity_autocomplete' export settings which is used to
  // expand a webform submission's entity references.
  $this->elementTypes['entity_autocomplete'] = 'entity_autocomplete';
  foreach ($elements as $element) {
    if (isset($element['#type'])) {
      $type = $this->elementManager
        ->getElementPluginId($element);
      $this->elementTypes[$type] = $type;
    }
  }
  return $this->elementTypes;
}