'csv'])] public function socialIssueList(Request $request, string $_format = 'csv'): StreamedResponse { if (!$this->security->isGranted('ROLE_ADMIN')) { throw new AccessDeniedHttpException('Only ROLE_ADMIN can export this list'); } $socialIssues = $this->socialIssueRepository->findAllOrdered(); $csv = $this->socialIssueCSVExportService->generateCsv($socialIssues); return new StreamedResponse( function () use ($csv) { foreach ($csv->chunk(1024) as $chunk) { echo $chunk; flush(); } }, Response::HTTP_OK, [ 'Content-Encoding' => 'none', 'Content-Type' => 'text/csv; charset=UTF-8', 'Content-Disposition' => 'attachment; users.csv', ] ); } }