You are here

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'
entity_export_csv.routing.yml in ./entity_export_csv.routing.yml
entity_export_csv.routing.yml

File

src/Controller/EntityExportCsvDownload.php, line 127

Class

EntityExportCsvDownload
Define the entity export csv download controller.

Namespace

Drupal\entity_export_csv\Controller

Code

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