public function WebformSubmissionExportImportImporter::getDestinationColumns in Webform 8.5
Same name and namespace in other branches
- 6.x modules/webform_submission_export_import/src/WebformSubmissionExportImportImporter.php \Drupal\webform_submission_export_import\WebformSubmissionExportImportImporter::getDestinationColumns()
Get destination (field and element) columns name.
Return value
array An associative array containing destination (field and element) columns name.
Overrides WebformSubmissionExportImportImporterInterface::getDestinationColumns
2 calls to WebformSubmissionExportImportImporter::getDestinationColumns()
- WebformSubmissionExportImportImporter::exportHeader in modules/
webform_submission_export_import/ src/ WebformSubmissionExportImportImporter.php - Create CSV export header.
- WebformSubmissionExportImportImporter::getSourceToDestinationColumnMapping in modules/
webform_submission_export_import/ src/ WebformSubmissionExportImportImporter.php - Get source (CSV) to destination (field and element) column mapping.
File
- modules/
webform_submission_export_import/ src/ WebformSubmissionExportImportImporter.php, line 1025
Class
- WebformSubmissionExportImportImporter
- Webform submission export import manager.
Namespace
Drupal\webform_submission_export_importCode
public function getDestinationColumns() {
$columns = [];
$field_definitions = $this
->getFieldDefinitions();
foreach ($field_definitions as $field_name => $field_definition) {
$columns[$field_name] = $field_definition['title'];
}
$elements = $this
->getElements();
foreach ($elements as $element_key => $element) {
$element_plugin = $this->elementManager
->getElementInstance($element);
$element_title = $element_plugin
->getAdminLabel($element);
$has_multiple_values = $element_plugin
->hasMultipleValues($element);
if (!$has_multiple_values && $element_plugin instanceof WebformCompositeBase) {
$composite_elements = $element_plugin
->getCompositeElements();
foreach ($composite_elements as $composite_element_key => $composite_element) {
$composite_element_name = $element_key . '__' . $composite_element_key;
$composite_element_plugin = $this->elementManager
->getElementInstance($composite_element);
$composite_element_title = $composite_element_plugin
->getAdminLabel($composite_element);
$t_args = [
'@element_title' => $element_title,
'@composite_title' => $composite_element_title,
];
$columns[$composite_element_name] = $this
->t('@element_title: @composite_title', $t_args);
}
}
elseif (!$has_multiple_values && $element_plugin instanceof WebformLikert) {
$questions = $element['#questions'];
foreach ($questions as $question_key => $question) {
$question_element_name = $element_key . '__' . $question_key;
$t_args = [
'@element_title' => $element_title,
'@question_title' => $question,
];
$columns[$question_element_name] = $this
->t('@element_title: @question_title', $t_args);
}
}
else {
$columns[$element_key] = $element_title;
}
}
return $columns;
}