From 6f260b28db852ca0138ace429b554cc03104c707 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rapha=C3=ABl=20Gertz?= Date: Mon, 28 Dec 2020 08:16:09 +0100 Subject: [PATCH] Add not found exception on location not found Change title scheme format Change section name Cleanup --- Controller/LocationController.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Controller/LocationController.php b/Controller/LocationController.php index 7f1a96b..aa21c34 100644 --- a/Controller/LocationController.php +++ b/Controller/LocationController.php @@ -23,13 +23,15 @@ class LocationController extends DefaultController { $doctrine = $this->getDoctrine(); //Fetch location - $location = $doctrine->getRepository(Location::class)->findOneById($id); + if (empty($location = $doctrine->getRepository(Location::class)->findOneById($id))) { + throw $this->createNotFoundException($this->translator->trans('Unable to find location: %id%', ['%id%' => $id])); + } //Set section - $section = $this->translator->trans($location); + $section = $this->translator->trans('Argentine Tango at '.$location); //Set title - $title = $section.' - '.$this->translator->trans($this->config['site']['title']); + $title = $this->translator->trans($this->config['site']['title']).' - '.$section; //Init context $context = []; @@ -84,7 +86,7 @@ class LocationController extends DefaultController { //Fetch locations //XXX: we want to display all active locations anyway - $locations = $doctrine->getRepository(Location::class)->fetchTranslatedLocationByDatePeriod($this->translator, $period/*, !$this->isGranted('IS_AUTHENTICATED_REMEMBERED')*/); + $locations = $doctrine->getRepository(Location::class)->findTranslatedSortedByPeriod($this->translator, $period); //Render the view return $this->render('@RapsysAir/location/view.html.twig', ['id' => $id, 'title' => $title, 'section' => $section, 'calendar' => $calendar, 'locations' => $locations]+$context+$this->context); -- 2.41.0