feat: streamlined filenames of downloaded teamer documents
addresses #8698updx6
This commit is contained in:
@@ -4,6 +4,7 @@ namespace App\Controller\Administrative\Document;
|
||||
|
||||
use App\Entity\Upload;
|
||||
use App\Repository\UploadRepository;
|
||||
use App\Service\Upload\DownloadNamer;
|
||||
use App\Service\Upload\UploadHandler;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
@@ -57,16 +58,13 @@ class BatchDownloadController extends AbstractController
|
||||
contentType: 'application/octet-stream'
|
||||
);
|
||||
|
||||
$namer = new DownloadNamer();
|
||||
|
||||
foreach ($uploads as $upload) {
|
||||
/** @var Upload $upload */
|
||||
$filename = $upload->getOriginalFilename();
|
||||
$teamer = $upload->getOwner()->getTeamer();
|
||||
$filename = $namer->nameForTeamer($upload, $teamer);
|
||||
$filepath = $this->uploadHandler->getUploadFilepath($upload);
|
||||
$extension = pathinfo($filepath, PATHINFO_EXTENSION);
|
||||
|
||||
// adopt potentially changed file extension
|
||||
if (false === str_ends_with($filename, $extension)) {
|
||||
$filename = $filename.'.'.$extension;
|
||||
}
|
||||
|
||||
try {
|
||||
$zip->addFileFromPath(fileName: $filename, path: $filepath);
|
||||
@@ -82,9 +80,9 @@ class BatchDownloadController extends AbstractController
|
||||
}
|
||||
}
|
||||
$zip->finish();
|
||||
});
|
||||
|
||||
$this->entityManager->flush();
|
||||
$this->entityManager->flush();
|
||||
});
|
||||
|
||||
$disposition = HeaderUtils::makeDisposition('attachment', $zipFilename, md5($zipFilename));
|
||||
$response->headers->set('Content-Disposition', $disposition);
|
||||
|
||||
Reference in New Issue
Block a user