add success page

This commit is contained in:
2025-02-22 17:55:37 +01:00
parent 74ff5a23e0
commit b50b2e0a62
4 changed files with 122 additions and 7 deletions

View File

@ -0,0 +1,50 @@
<?php
declare(strict_types=1);
namespace App\Service;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Response;
class EventService
{
private const EVENT_DATA = [
'title' => 'FWS Abiball',
'description' => 'Der Abiball der Freien Waldorfschule Bremen Osterholz und Touler Straße',
'location' => 'Graubünder Straße 2, 28209 Bremen',
'start' => '20240615T180000',
'end' => '20240615T220000',
];
public function generateIcs(): Response
{
$data = [
'BEGIN:VCALENDAR',
'VERSION:2.0',
'BEGIN:VEVENT',
'DTSTART:' . self::EVENT_DATA['start'],
'DTEND:' . self::EVENT_DATA['end'],
'SUMMARY:' . self::EVENT_DATA['title'],
'DESCRIPTION:' . self::EVENT_DATA['description'],
'LOCATION:' . self::EVENT_DATA['location'],
'END:VEVENT',
'END:VCALENDAR'
];
return new Response(implode("\r\n", $data), headers: [
'Content-Type' => 'text/calendar; charset=utf-8',
'Content-Disposition' => 'attachment; filename="event.ics"'
]);
}
public function generateGoogleRedirect(): Response
{
return new RedirectResponse('https://calendar.google.com/calendar/render?' . http_build_query([
'action' => 'TEMPLATE',
'text' => self::EVENT_DATA['title'],
'dates' => self::EVENT_DATA['start'] . '/' . self::EVENT_DATA['end'],
'details' => self::EVENT_DATA['description'],
'location' => self::EVENT_DATA['location'],
]));
}
}