public function ExportDownload::download in Bibliography & Citation 2.0.x
Same name and namespace in other branches
- 8 modules/bibcite_export/src/Controller/ExportDownload.php \Drupal\bibcite_export\Controller\ExportDownload::download()
Download file callback.
Parameters
\Symfony\Component\HttpFoundation\Request $request: Request object.
\Drupal\file\FileInterface $file: File to download.
Return value
\Symfony\Component\HttpFoundation\Response Response object.
1 string reference to 'ExportDownload::download'
- bibcite_export.routing.yml in modules/
bibcite_export/ bibcite_export.routing.yml - modules/bibcite_export/bibcite_export.routing.yml
File
- modules/
bibcite_export/ src/ Controller/ ExportDownload.php, line 54
Class
- ExportDownload
- Download a file created by "Export all" form.
Namespace
Drupal\bibcite_export\ControllerCode
public function download(Request $request, FileInterface $file) {
$response = new Response();
$response->headers
->set('Cache-Control', 'no-cache');
$response->headers
->set('Content-type', 'text/plain');
$response->headers
->set('Content-Disposition', 'attachment; filename="' . $file
->getFilename() . '";');
$response
->setContent(file_get_contents($file
->getFileUri()));
return $response;
}