]> Raphaƫl G. Git Repositories - airbundle/blobdiff - Controller/LocationController.php
Add location prefill when on a location view
[airbundle] / Controller / LocationController.php
index bf5f62d860409f9c2ce74d0c0d437a1df96b8c76..7f1a96bd4b70bd58aedc73ba74ed9e67862e3fcd 100644 (file)
@@ -48,7 +48,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 +80,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)->fetchTranslatedLocationByDatePeriod($this->translator, $period/*, !$this->isGranted('IS_AUTHENTICATED_REMEMBERED')*/);
 
                //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);
        }
 }