Skip to content
Snippets Groups Projects

Refactoring and drupal 10 readiness

5 files
+ 42
23
Compare changes
  • Side-by-side
  • Inline
Files
5
@@ -11,15 +11,15 @@ use Drupal\Core\File\FileSystem;
use Drupal\Core\Utility\Token;
use Drupal\field\Entity\FieldConfig;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\BinaryFileResponse;
use Symfony\Component\HttpKernel\Exception\ServiceUnavailableHttpException;
use PclZip;
/**
* Default controller for the download module.
*/
class DefaultController extends ControllerBase {
use PclZip;
/**
* The entity type manager.
*
@@ -130,19 +130,19 @@ class DefaultController extends ControllerBase {
}
$filename = $filename . '.zip';
$tmp_file = file_save_data('', 'temporary://' . $filename);
$tmp_file->status = 0;
$tmp_file->save();
$archive = new PclZip($this->fileSystem->realpath($tmp_file->getFileUri()));
$tmpFilePath = $this->fileSystem->saveData('', "temporary://${filename}");
$archive = new PclZip($tmpFilePath);
$archive->add($files, PCLZIP_OPT_REMOVE_ALL_PATH);
$this->moduleHandler->invokeAll('download_download', [$files, $entity]);
header("Content-Type: application/force-download");
header('Content-Description: File Transfer');
header('Content-Disposition: inline; filename=' . $filename);
readfile($this->fileSystem->realpath($tmp_file->getFileUri()));
exit();
$headers = [
'Content-Type' => 'application/force-download',
'Content-Description' => 'File Transfer',
'Content-Disposition' => "inline; filename=${filename}",
];
return new BinaryFileResponse($tmpFilePath, 200, $headers, TRUE);
}
/**
Loading