public function DownloadController::download in Open Social 8
Same name and namespace in other branches
- 8.2 modules/social_features/social_user_export/src/Controller/DownloadController.php \Drupal\social_user_export\Controller\DownloadController::download()
- 8.3 modules/social_features/social_user_export/src/Controller/DownloadController.php \Drupal\social_user_export\Controller\DownloadController::download()
- 8.4 modules/social_features/social_user_export/src/Controller/DownloadController.php \Drupal\social_user_export\Controller\DownloadController::download()
Returns headers to force download file.
Parameters
string $name: The name of the file.
Return value
\Symfony\Component\HttpFoundation\BinaryFileResponse The file object.
1 string reference to 'DownloadController::download'
- social_user_export.routing.yml in modules/
social_features/ social_user_export/ social_user_export.routing.yml - modules/social_features/social_user_export/social_user_export.routing.yml
File
- modules/
social_features/ social_user_export/ src/ Controller/ DownloadController.php, line 23
Class
- DownloadController
- Returns responses for social_user_export module routes.
Namespace
Drupal\social_user_export\ControllerCode
public function download($name) {
$file_path = file_directory_temp() . '/' . $name;
$response = new BinaryFileResponse($file_path);
$disposition = $response->headers
->makeDisposition(ResponseHeaderBag::DISPOSITION_ATTACHMENT, $name);
$response->headers
->set('Content-Disposition', $disposition);
return $response;
}