find([ 'order' => 'DESC', ]); $days = []; foreach ($snapshots as $snapshot) { $day = $snapshot->getDate()->format('d/m'); if (!in_array($day, $days)) { $days[$snapshot->getDate()->format('Y-m-d')] = $day; } } return $this->render('events.html.twig', [ 'snapshots' => $snapshots, 'days' => $days, 'date' => $date, ]); } /** * @Route("/download_snapshot", name="download_snapshot") */ public function downloadSnapshot(SnapshotRepository $snapshotRepository, Request $request): BinaryFileResponse { $src = ltrim($request->query->get('src'), '/'); $snapshots = $snapshotRepository->find(); foreach ($snapshots as $snapshot) { if ($snapshot->getMovie() === $src) { return new BinaryFileResponse($src, 200, [ 'Content-Type' => 'application/octect-stream', 'Content-Length' => filesize($src), 'Content-Disposition' => sprintf('attachment; filename="%s"', basename($src)), 'Content-Transfer-Encoding' => 'binary', ]); } } throw $this->createNotFoundException(); } }