protected function D7WebformSubmission::buildSubmittedData in Webform: Migrate 8.2
Same name and namespace in other branches
- 8 src/Plugin/migrate/source/d7/D7WebformSubmission.php \Drupal\webform_migrate\Plugin\migrate\source\d7\D7WebformSubmission::buildSubmittedData()
Build submitted data from webform submitted data table.
1 call to D7WebformSubmission::buildSubmittedData()
- D7WebformSubmission::prepareRow in src/
Plugin/ migrate/ source/ d7/ D7WebformSubmission.php - Adds additional data to the row.
File
- src/
Plugin/ migrate/ source/ d7/ D7WebformSubmission.php, line 81
Class
- D7WebformSubmission
- Drupal 7 webform submission source from database.
Namespace
Drupal\webform_migrate\Plugin\migrate\source\d7Code
protected function buildSubmittedData($sid) {
$query = $this
->select('webform_submitted_data', 'wfsd');
$query
->innerJoin('webform_component', 'wc', 'wc.nid=wfsd.nid AND wc.cid=wfsd.cid');
$query
->fields('wfsd', [
'no',
'data',
])
->fields('wc', [
'form_key',
'extra',
'type',
'pid',
]);
$wf_submissions = $query
->condition('sid', $sid)
->execute();
$submitted_data = [];
foreach ($wf_submissions as $wf_submission) {
$extra = unserialize($wf_submission['extra']);
// Nested form values will get their parent form item's ID as suffix, so
// the source and the destination form keys are not always equal.
$src_form_key = $wf_submission['form_key'];
$destination_form_key = $wf_submission['pid'] ? "{$src_form_key}_{$wf_submission['pid']}" : $src_form_key;
$is_multiple = !empty($extra['multiple']) || $wf_submission['type'] === 'grid';
$item = $is_multiple ? $submitted_data[$destination_form_key] ?? [] : $wf_submission['data'];
if ($is_multiple && !empty($wf_submission['data'])) {
$item[$wf_submission['no']] = $wf_submission['data'];
}
if (!empty($item)) {
$submitted_data[$destination_form_key] = $item;
}
}
return $submitted_data;
}