src/Controller/CalendarController.php line 16

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  4. use Symfony\Component\Routing\Annotation\Route;
  5. /**
  6.  * @Route("/termine", name="calendar_")
  7.  */
  8. class CalendarController extends AbstractController
  9. {
  10.     /**
  11.      * @Route("/", name="index")
  12.      */
  13.     public function index()
  14.     {
  15.         /* Get meta from api */
  16.         $metaJson null;
  17.         try {
  18.             $metaJsonPath = @file_get_contents('https://api.ctc-rheda.de/api/singletons/get/calendar?token=863f1ccdb97de3b924e07b600ce0f5');
  19.             if ($metaJsonPath !== false) {
  20.                 $metaJson json_decode($metaJsonPathtrue);
  21.             }
  22.         } catch (\Exception $e) {
  23.             error_log('API Error in CalendarController: ' $e->getMessage());
  24.         }
  25.         
  26.         // Fallback if API is not available
  27.         if ($metaJson === null) {
  28.             $metaJson = [
  29.                 'title' => 'Termine',
  30.                 'description' => 'Termine und Veranstaltungen des CTC.',
  31.                 'keywords' => 'Tennis, Termine, CTC, Rheda'
  32.             ];
  33.         }
  34.         return $this->render('pages/calendar.html.twig', [
  35.             // passed dates to template
  36.             'page' => array(
  37.                 'title' => 'Termine',
  38.                 'meta' => $metaJson
  39.             ),
  40.         ]);
  41.     }
  42. }