+ return $this->render('@RapsysAir/session/index.html.twig', ['title' => $title, 'section' => $section, 'calendar' => $calendar, 'locations' => $locations]+$this->context);
+ }
+
+ /**
+ * List all sessions for tango argentin
+ *
+ * @desc Display all sessions in tango argentin json format
+ *
+ * @todo Drop it if unused by tangoargentin ???
+ *
+ * @param Request $request The request instance
+ *
+ * @return Response The rendered view or redirection
+ */
+ public function tangoargentin(Request $request): Response {
+ //Fetch doctrine
+ $doctrine = $this->getDoctrine();
+
+ //Compute period
+ $period = new \DatePeriod(
+ //Start from first monday of week
+ new \DateTime('today'),
+ //Iterate on each day
+ new \DateInterval('P1D'),
+ //End with next sunday and 4 weeks
+ new \DateTime('+2 week')
+ );
+
+ //Retrieve events to update
+ $sessions = $doctrine->getRepository(Session::class)->fetchAllByDatePeriod($period, $request->getLocale());
+
+ //Init return array
+ $ret = [];
+
+ //Iterate on sessions
+ foreach($sessions as $sessionId => $session) {
+ //Set title
+ $title = $session['au_pseudonym'].' '.$this->translator->trans('at '.$session['l_title']);
+
+ //Use Transliterator if available
+ if (class_exists('Transliterator')) {
+ $trans = \Transliterator::create('Any-Latin; Latin-ASCII; Upper()');
+ $title = $trans->transliterate($title);
+ } else {
+ $title = strtoupper($title);
+ }
+
+ //Set rate
+ $rate = 'Au chapeau';
+
+ //Without hat
+ if ($session['p_hat'] === null) {
+ //Set rate
+ $rate = 'Gratuit';
+
+ //With rate
+ if ($session['p_rate'] !== null) {
+ //Set rate
+ $rate = $session['p_rate'].' €';
+ }
+ //With hat
+ } else {
+ //With rate
+ if ($session['p_rate'] !== null) {
+ //Set rate
+ $rate .= ', idéalement '.$session['p_rate'].' €';
+ }
+ }
+
+ //Store session data
+ $ret[$sessionId] = [
+ 'start' => $session['start']->format(\DateTime::ISO8601),
+ 'stop' => $session['start']->format(\DateTime::ISO8601),
+ 'title' => $title,
+ 'short' => $session['p_short'],
+ 'rate' => $rate,
+ 'location' => implode(' ', [$session['l_address'], $session['l_zipcode'], $session['l_city']]),
+ 'status' => (empty($session['a_canceled']) && empty($session['locked']))?'confirmed':'cancelled',
+ 'updated' => $session['updated']->format(\DateTime::ISO8601),
+ 'organizer' => $session['au_forename'],
+ 'source' => $this->router->generate('rapsys_air_session_view', ['id' => $sessionId], UrlGeneratorInterface::ABSOLUTE_URL)
+ ];
+ }
+
+ //Set response
+ $response = new Response(json_encode($ret));
+
+ //Set header
+ $response->headers->set('Content-Type', 'application/json');
+
+ //Send response
+ return $response;