public function EntityExportCsvDownload::downloadExport in Entity Export CSV 8
Download entity content exported file.
Return value
\Symfony\Component\HttpFoundation\Response The response.
1 string reference to 'EntityExportCsvDownload::downloadExport'
File
- src/
Controller/ EntityExportCsvDownload.php, line 127
Class
- EntityExportCsvDownload
- Define the entity export csv download controller.
Namespace
Drupal\entity_export_csv\ControllerCode
public function downloadExport() {
$token = $this
->getRequest()->query
->get('token');
$file_uri = $this
->getRequest()->query
->get('file');
if (empty($token) || !$this->csrfToken
->validate($token, $file_uri)) {
throw new AccessDeniedHttpException();
}
if (!isset($file_uri) || !file_exists($file_uri)) {
throw new NotFoundHttpException($this
->t('Missing or not found entity content exported file.'));
}
return (new BinaryFileResponse($file_uri))
->deleteFileAfterSend(TRUE)
->setContentDisposition('attachment', basename($file_uri));
}