feat: basic themes for event sites
This commit is contained in:
@@ -20,6 +20,8 @@ class BookingService
|
||||
public const BOOKING_EDIT_KEY = 'booking_edit';
|
||||
public const RETURN_URL_KEY = 'booking_return_url';
|
||||
public const DEFAULT_RETURN_URL = 'https://www.ep-reisen.de';
|
||||
public const THEME_KEY = 'booking_theme';
|
||||
public const DEFAULT_THEME = 'base';
|
||||
|
||||
public function __construct(
|
||||
private readonly TravelDataService $travelDataService,
|
||||
@@ -188,6 +190,33 @@ class BookingService
|
||||
return $request->getSession()->get(self::RETURN_URL_KEY, self::DEFAULT_RETURN_URL);
|
||||
}
|
||||
|
||||
/**
|
||||
* Stores the theme identifier in the session.
|
||||
*
|
||||
* Sanitizes the theme value to allow only alphanumeric characters and hyphens.
|
||||
* Falls back to the default theme if empty or invalid.
|
||||
*/
|
||||
public function storeTheme(Request $request, string $theme): void
|
||||
{
|
||||
$sanitized = preg_replace('/[^a-zA-Z0-9-]/', '', $theme);
|
||||
|
||||
if ('' === $sanitized) {
|
||||
$sanitized = self::DEFAULT_THEME;
|
||||
}
|
||||
|
||||
$request->getSession()->set(self::THEME_KEY, $sanitized);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the theme identifier from the session.
|
||||
*
|
||||
* Returns the default theme if not set in session.
|
||||
*/
|
||||
public function getTheme(Request $request): string
|
||||
{
|
||||
return $request->getSession()->get(self::THEME_KEY, self::DEFAULT_THEME);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a fresh booking session with the provided travel parameters.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user