public function WebformSubmissionExporter::writeRecords in Webform 8.5
Same name and namespace in other branches
- 6.x src/WebformSubmissionExporter.php \Drupal\webform\WebformSubmissionExporter::writeRecords()
Write webform results header to export file.
Parameters
\Drupal\webform\WebformSubmissionInterface[] $webform_submissions: A webform submission.
Overrides WebformSubmissionExporterInterface::writeRecords
1 call to WebformSubmissionExporter::writeRecords()
- WebformSubmissionExporter::generate in src/
WebformSubmissionExporter.php - Execute results exporter and write export to a temp file.
File
- src/
WebformSubmissionExporter.php, line 796
Class
- WebformSubmissionExporter
- Webform submission exporter.
Namespace
Drupal\webformCode
public function writeRecords(array $webform_submissions) {
$export_options = $this
->getExportOptions();
$webform = $this
->getWebform();
$is_archive = $this
->isArchive() && $export_options['files'];
$files_directories = [];
if ($is_archive) {
$stream_wrappers = array_keys($this->streamWrapperManager
->getNames(StreamWrapperInterface::WRITE_VISIBLE));
foreach ($stream_wrappers as $stream_wrapper) {
$files_directory = $this->fileSystem
->realpath($stream_wrapper . '://webform/' . $webform
->id());
$files_directories[] = $files_directory;
}
}
$this
->getExporter()
->openExport();
foreach ($webform_submissions as $webform_submission) {
if ($is_archive) {
foreach ($files_directories as $files_directory) {
$submission_directory = $files_directory . '/' . $webform_submission
->id();
if (file_exists($submission_directory)) {
$file_name = $this
->getSubmissionBaseName($webform_submission);
$this
->getExporter()
->addToArchive($submission_directory, $file_name, [
'remove_path' => $submission_directory,
]);
}
}
}
$this
->getExporter()
->writeSubmission($webform_submission);
}
$this
->getExporter()
->closeExport();
}