add success page (#27)

Reviewed-on: #27
This commit is contained in:
2025-02-23 16:39:02 +00:00
parent 74ff5a23e0
commit 0000a75490
5 changed files with 170 additions and 34 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' => 'Abiball 2025',
'description' => 'Der Abiball der Freien Waldorfschule Bremen Osterholz und Touler Straße',
'location' => 'Graubündener Str. 4, 28325 Bremen',
'start' => '20250628T173000',
'end' => '20250629T030000',
];
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'],
]));
}
}