You are here

public function DownloadController::download in Open Social 8.2

Same name and namespace in other branches
  1. 8 modules/social_features/social_user_export/src/Controller/DownloadController.php \Drupal\social_user_export\Controller\DownloadController::download()
  2. 8.3 modules/social_features/social_user_export/src/Controller/DownloadController.php \Drupal\social_user_export\Controller\DownloadController::download()
  3. 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\Controller

Code

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;
}