<?php
namespace App\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Routing\Annotation\Route;
/**
* @Route("/sponsoren", name="sponsors_")
*/
class SponsorsController extends AbstractController
{
/**
* @Route("/", name="index")
*/
public function index()
{
/* Get sponsors from api */
$sponsorsJson = ['entries' => []];
try {
$sponsorsJsonPath = @file_get_contents('https://api.ctc-rheda.de/api/collections/get/sponsors?token=863f1ccdb97de3b924e07b600ce0f5');
if ($sponsorsJsonPath !== false) {
$sponsorsJson = json_decode($sponsorsJsonPath, true) ?: ['entries' => []];
}
} catch (\Exception $e) {
error_log('API Error in SponsorsController (sponsors): ' . $e->getMessage());
}
/* Get meta from api */
$metaJson = null;
try {
$metaJsonPath = @file_get_contents('https://api.ctc-rheda.de/api/singletons/get/sponsors?token=863f1ccdb97de3b924e07b600ce0f5');
if ($metaJsonPath !== false) {
$metaJson = json_decode($metaJsonPath, true);
}
} catch (\Exception $e) {
error_log('API Error in SponsorsController (meta): ' . $e->getMessage());
}
// Fallback if API is not available
if ($metaJson === null) {
$metaJson = [
'title' => 'Sponsoren',
'description' => 'Alle Sponsoren des Cor Tennisclub Rheda e.V.',
'keywords' => 'Tennis, Sponsoren, CTC, Rheda'
];
}
return $this->render('pages/sponsors.html.twig', [
// passed dates to template
'sponsors' => $sponsorsJson['entries'],
'page' => array(
'title' => 'Sponsoren',
'description' => 'Alle Sponsoren des Cor Tennisclub Rheda e.V.',
'meta' => $metaJson
)
]);
}
}