protected function WebformSubmissionExportImportImporter::importElement 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::importElement()
Import element.
Parameters
array $element: A managed file element.
mixed $value: File URI(s) from CSV record.
\Drupal\webform\WebformSubmissionInterface|null $webform_submission: Existing submission or NULL if new submission.
array $errors: An array of error messages.
Return value
array|int|null An array of multiple files, single file id, or NULL if file could not be imported.
1 call to WebformSubmissionExportImportImporter::importElement()
- WebformSubmissionExportImportImporter::importPrepareRecord in modules/
webform_submission_export_import/ src/ WebformSubmissionExportImportImporter.php - Prepare import submission record.
File
- modules/
webform_submission_export_import/ src/ WebformSubmissionExportImportImporter.php, line 669
Class
- WebformSubmissionExportImportImporter
- Webform submission export import manager.
Namespace
Drupal\webform_submission_export_importCode
protected function importElement(array $element, $value, WebformSubmissionInterface $webform_submission = NULL, array &$errors) {
$element_plugin = $this->elementManager
->getElementInstance($element);
if ($value === '') {
// Empty: Convert multiple values to an empty array or NULL value.
return $element_plugin
->hasMultipleValues($element) ? [] : NULL;
}
elseif ($element_plugin instanceof WebformManagedFileBase) {
// Files: Convert File URL to file object.
return $this
->importManageFileElement($element, $value, $webform_submission, $errors);
}
elseif ($element_plugin instanceof WebformElementEntityReferenceInterface) {
// Entity references: Convert entity UUIDs to internal IDs.
return $this
->importEntityReferenceElement($element, $value, $webform_submission, $errors);
}
elseif ($element_plugin
->isComposite()) {
// Composite: Decode YAML.
return $this
->importCompositeElement($element, $value, $webform_submission, $errors);
}
elseif ($element_plugin
->hasMultipleValues($element)) {
// Multiple: Convert to comma separated values to array.
return $this
->importMultipleElement($element, $value, $webform_submission, $errors);
}
else {
return $value;
}
}