public function YamlFormExporterBase::getSubmissionBaseName in YAML Form 8
Get form submission base file name.
Parameters
\Drupal\yamlform\YamlFormSubmissionInterface $yamlform_submission: A form submission.
Return value
string Form submission's base file name.
Overrides YamlFormExporterInterface::getSubmissionBaseName
2 calls to YamlFormExporterBase::getSubmissionBaseName()
- JsonYamlFormExporter::writeSubmission in src/
Plugin/ YamlFormExporter/ JsonYamlFormExporter.php - Write submission to export.
- YamlYamlFormExporter::writeSubmission in src/
Plugin/ YamlFormExporter/ YamlYamlFormExporter.php - Write submission to export.
File
- src/
YamlFormExporterBase.php, line 233
Class
- YamlFormExporterBase
- Provides a base class for a results exporter.
Namespace
Drupal\yamlformCode
public function getSubmissionBaseName(YamlFormSubmissionInterface $yamlform_submission) {
$export_options = $this
->getConfiguration();
$file_name = $export_options['file_name'];
$token_data = [
'yamlform' => $yamlform_submission
->getYamlForm(),
'yamlform_submission' => $yamlform_submission,
];
$token_options = [
'clear' => TRUE,
];
$file_name = \Drupal::token()
->replace($file_name, $token_data, $token_options);
// Sanitize file name.
// @see http://stackoverflow.com/questions/2021624/string-sanitizer-for-filename
$file_name = preg_replace('([^\\w\\s\\d\\-_~,;:\\[\\]\\(\\].]|[\\.]{2,})', '', $file_name);
$file_name = preg_replace('/\\s+/', '-', $file_name);
return $file_name;
}