Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
download
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
download
Merge requests
!5
Refactoring and drupal 10 readiness
Code
Review changes
Check out branch
Download
Patches
Plain diff
Open
Refactoring and drupal 10 readiness
issue/download-3296982:3296982-refactoring-and-D10-readiness
into
3.x
Overview
0
Commits
1
Pipelines
0
Changes
5
Open
David Sarre
requested to merge
issue/download-3296982:3296982-refactoring-and-D10-readiness
into
3.x
1 year ago
Overview
0
Commits
1
Pipelines
0
Changes
5
Expand
Combining drupal 10 rector patch from
#3296982
and Ruby232 refactoring from
#3284143
0
0
Merge request reports
Compare
3.x
3.x (HEAD)
and
latest version
latest version
07ae9234
1 commit,
1 year ago
5 files
+
42
−
23
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
5
Search (e.g. *.vue) (Ctrl+P)
src/Controller/DefaultController.php
+
11
−
11
Options
@@ -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