public function YamlFormSubmissionExporter::writeRecords in YAML Form 8
Write form results header to export file.
Parameters
\Drupal\yamlform\YamlFormSubmissionInterface[] $yamlform_submissions: A form submission.
Overrides YamlFormSubmissionExporterInterface::writeRecords
1 call to YamlFormSubmissionExporter::writeRecords()
- YamlFormSubmissionExporter::generate in src/
YamlFormSubmissionExporter.php - Execute results exporter and write export to a temp file.
File
- src/
YamlFormSubmissionExporter.php, line 639
Class
- YamlFormSubmissionExporter
- Form submission exporter.
Namespace
Drupal\yamlformCode
public function writeRecords(array $yamlform_submissions) {
$export_options = $this
->getExportOptions();
$yamlform = $this
->getYamlForm();
$is_archive = $this
->isArchive() && $export_options['files'];
$files_directories = [];
if ($is_archive) {
$archiver = new ArchiveTar($this
->getArchiveFilePath(), 'gz');
$stream_wrappers = array_keys($this->streamWrapperManager
->getNames(StreamWrapperInterface::WRITE_VISIBLE));
foreach ($stream_wrappers as $stream_wrapper) {
$files_directory = \Drupal::service('file_system')
->realpath($stream_wrapper . '://yamlform/' . $yamlform
->id());
$files_directories[] = $files_directory;
}
}
$this
->getExporter()
->openExport();
foreach ($yamlform_submissions as $yamlform_submission) {
if ($is_archive) {
foreach ($files_directories as $files_directory) {
$submission_directory = $files_directory . '/' . $yamlform_submission
->id();
if (file_exists($submission_directory)) {
$file_name = $this
->getSubmissionBaseName($yamlform_submission);
$archiver
->addModify($submission_directory, $file_name, $submission_directory);
}
}
}
$this
->getExporter()
->writeSubmission($yamlform_submission);
}
$this
->getExporter()
->closeExport();
}