By dawehner on
Change record status:
Published (View all published change records)
Project:
Introduced in branch:
8.x
Issue links:
Description:
Instead of calling file_download to serve a downloaded file you should use the file download controller Drupal\system\FileDownloadController, which itself gets the module handler Drupal::moduleHandler() injected.
Before
return file_download('temporary', 'config.tar.gz');
Now
use Drupal\system\FileDownloadController;
$this->fileDownloadController = new FileDownloadController($module_handler);
$request = new Request(array('file' => 'config.tar.gz'));
return $this->fileDownloadController->download($request, 'temporary');