+ //Fetch calendar
+ $this->context['calendar'] = $this->doctrine->getRepository(Session::class)->findAllByPeriodAsCalendarArray($this->period, !$this->checker->isGranted('IS_AUTHENTICATED_REMEMBERED'), $this->context['location']['latitude'], $this->context['location']['longitude']);
+
+ //Set dances
+ $this->context['dances'] = [];
+
+ //Iterate on each calendar
+ foreach($this->context['calendar'] as $date => $calendar) {
+ //Iterate on each session
+ foreach($calendar['sessions'] as $sessionId => $session) {
+ //Session with application dance
+ if (!empty($session['application']['dance'])) {
+ //Add dance
+ $this->context['dances'][$session['application']['dance']['id']] = $session['application']['dance'];
+ }
+ }
+ }
+
+ //Get locations at less than 2 km
+ $this->context['locations'] = $this->doctrine->getRepository(Location::class)->findAllByLatitudeLongitudeAsArray($this->context['location']['latitude'], $this->context['location']['longitude'], $this->period, 2);
+
+ //Set modified
+ //XXX: dance modified is already computed inside calendar modified
+ $this->modified = max(array_merge([$this->context['location']['modified']], array_map(function ($v) { return $v['modified']; }, array_merge($this->context['calendar'], $this->context['locations']))));
+
+ //Create response
+ $response = new Response();
+
+ //With logged user
+ if ($this->checker->isGranted('IS_AUTHENTICATED_REMEMBERED')) {
+ //Set last modified
+ $response->setLastModified(new \DateTime('-1 year'));
+
+ //Set as private
+ $response->setPrivate();
+ //Without logged user
+ } else {
+ //Set etag
+ //XXX: only for public to force revalidation by last modified
+ $response->setEtag(md5(serialize(array_merge($this->context['location'], $this->context['calendar'], $this->context['locations']))));
+
+ //Set last modified
+ $response->setLastModified($this->modified);
+
+ //Set as public
+ $response->setPublic();
+
+ //Without role and modification
+ if ($response->isNotModified($request)) {
+ //Return 304 response
+ return $response;
+ }
+ }
+
+ //Add multi map
+ $this->context['multimap'] = $this->map->getMultiMap($this->context['location']['multimap'], $this->modified->getTimestamp(), $this->context['locations']);