public function WebformLikert::buildExportRecord in Webform 8.5
Same name and namespace in other branches
- 6.x src/Plugin/WebformElement/WebformLikert.php \Drupal\webform\Plugin\WebformElement\WebformLikert::buildExportRecord()
Build an element's export row.
Parameters
array $element: An element.
\Drupal\webform\WebformSubmissionInterface $webform_submission: A webform submission.
array $export_options: An associative array of export options.
Return value
array An array containing the element's export row.
Overrides WebformElementBase::buildExportRecord
See also
\Drupal\webform\WebformSubmissionExporterInterface::getDefaultExportOptions
File
- src/
Plugin/ WebformElement/ WebformLikert.php, line 272
Class
- WebformLikert
- Provides a 'likert' element.
Namespace
Drupal\webform\Plugin\WebformElementCode
public function buildExportRecord(array $element, WebformSubmissionInterface $webform_submission, array $export_options) {
$value = $this
->getValue($element, $webform_submission);
$record = [];
foreach ($element['#questions'] as $question_key => $question_label) {
$answer_value = isset($value[$question_key]) ? $value[$question_key] : NULL;
if ($export_options['likert_answers_format'] === 'key') {
$record[] = $answer_value;
}
else {
$record[] = WebformOptionsHelper::getOptionText($answer_value, $element['#answers'], TRUE);
}
}
return $record;
}