feat: download ZIP archive of invoices with status 'paid'

This commit is contained in:
Björn Fromme
2025-01-31 18:08:52 +01:00
parent d39f75d831
commit 3f839f9082
9 changed files with 274 additions and 3 deletions
@@ -4,6 +4,7 @@ namespace App\Controller\Common;
use App\Entity\Upload;
use App\Service\Upload\UploadHandler;
use Doctrine\ORM\EntityManagerInterface;
use Psr\Log\LoggerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException;
@@ -17,6 +18,7 @@ class DownloadController extends AbstractController
{
public function __construct(
private readonly UploadHandler $uploadHandler,
private readonly EntityManagerInterface $entityManager,
private readonly LoggerInterface $logger
) {
}
@@ -31,6 +33,13 @@ class DownloadController extends AbstractController
$inline = (bool) $request->get('inline');
$disposition = $inline ? ResponseHeaderBag::DISPOSITION_INLINE : ResponseHeaderBag::DISPOSITION_ATTACHMENT;
// mark file downloaded
$upload
->setDownloaded()
->setDownloadedBy($this->getUser()->getUserIdentifier())
;
$this->entityManager->flush();
$this->logger->info('Download file', [
'file_id' => $upload->getId(),
'file_filename' => $upload->getOriginalFilename(),