add success page
This commit is contained in:
50
src/Service/EventService.php
Normal file
50
src/Service/EventService.php
Normal 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'],
|
||||
]));
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user