X-Git-Url: https://git.rapsys.eu/airbundle/blobdiff_plain/da06445ebe892c527ee65cddbac923faf1a71418..265e617299f70a9bedaa176240914c1de609266e:/Controller/LocationController.php diff --git a/Controller/LocationController.php b/Controller/LocationController.php index bf5f62d..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 = []; @@ -48,7 +50,9 @@ class LocationController extends DefaultController { 'user' => $this->getUser()->getId(), //Set default slot to evening //XXX: default to Evening (3) - 'slot' => $doctrine->getRepository(Slot::class)->findOneById(3) + 'slot' => $doctrine->getRepository(Slot::class)->findOneById(3), + //Set default location to current one + 'location' => $location ]); //Add form to context @@ -78,9 +82,13 @@ class LocationController extends DefaultController { ); //Fetch calendar - $calendar = $doctrine->getRepository(Session::class)->fetchCalendarByDatePeriod($this->translator, $period, $id, $request->get('session')); + $calendar = $doctrine->getRepository(Session::class)->fetchCalendarByDatePeriod($this->translator, $period, $id, $request->get('session'), !$this->isGranted('IS_AUTHENTICATED_REMEMBERED')); + + //Fetch locations + //XXX: we want to display all active locations anyway + $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]+$context+$this->context); + return $this->render('@RapsysAir/location/view.html.twig', ['id' => $id, 'title' => $title, 'section' => $section, 'calendar' => $calendar, 'locations' => $locations]+$context+$this->context); } }