getRepository(Photos::class)->findAllOrderByLatest(); $albums = []; foreach ($photos as $index => $photo) { $albums[] = [ 'title' => $photo->getTitle(), 'date' => $photo->getDate(), 'category' => $photo->getCategory()->getTitle(), 'thumbnail' => 'photos/' . strtolower(str_replace(' ', '_', $photo->getTitle())) . '/' . $photo->getThumbnail(), 'url' => $photo->getUrl(), ]; } return $this->render('front/photos/index.html.twig', [ 'photos' => $albums ]); } #[Route('/photos/{url:photos}', name: 'front_end_photos_detail')] public function detail(Photos $photos): Response { $album = []; $uploads = $photos->getUploads(); $album = [ 'title' => $photos->getTitle(), 'category' => $photos->getCategory()->getTitle(), 'urlSafeCategory' => $photos->getCategory()->getUrlSafeTitle(), 'text' => $photos->getText(), 'date' => $photos->getDate() ]; foreach ($uploads as $index => $upload) { $filePath = 'photos/' . strtolower(str_replace(' ', '_', $album['title'])) . '/' . $upload->getFile(); $album['uploads'][] = [ 'file' => $filePath, 'alt' => $upload->getAltText(), 'equipment' => $upload->getEquipment(), 'caption' => $upload->getCaption(), 'location' => $upload->getLocation(), 'date' => $upload->getDate() ]; } return $this->render('front/photos/detail.html.twig', [ 'photos' => $album ]); } }