public function WebformResultsExportController::file in Webform 8.5
Same name and namespace in other branches
- 6.x src/Controller/WebformResultsExportController.php \Drupal\webform\Controller\WebformResultsExportController::file()
Returns webform submission results as CSV file.
Parameters
\Symfony\Component\HttpFoundation\Request $request: The current request.
string $filename: CSV file name.
Return value
array|\Symfony\Component\HttpFoundation\Response A response that renders or redirects to the CSV file.
2 string references to 'WebformResultsExportController::file'
- webform.routing.yml in ./
webform.routing.yml - webform.routing.yml
- webform_node.routing.yml in modules/
webform_node/ webform_node.routing.yml - modules/webform_node/webform_node.routing.yml
File
- src/
Controller/ WebformResultsExportController.php, line 152
Class
- WebformResultsExportController
- Controller routines for webform submission export.
Namespace
Drupal\webform\ControllerCode
public function file(Request $request, $filename) {
list($webform, $source_entity) = $this->requestHandler
->getWebformEntities();
$this->submissionExporter
->setWebform($webform);
$this->submissionExporter
->setSourceEntity($source_entity);
$file_path = $this->submissionExporter
->getFileTempDirectory() . '/' . $filename;
if (!file_exists($file_path)) {
$t_args = [
':href' => $this->requestHandler
->getUrl($webform, $source_entity, 'webform.results_export')
->toString(),
];
$build = [
'#markup' => $this
->t('No export file ready for download. The file may have already been downloaded by your browser. Visit the <a href=":href">download export webform</a> to create a new export.', $t_args),
];
return $build;
}
else {
return $this
->downloadFile($file_path);
}
}