feat: gravatar integration

This commit is contained in:
Björn Fromme
2026-03-16 11:59:11 +01:00
parent 142db19627
commit 5d69e4a8aa
5 changed files with 94 additions and 20 deletions
+8 -4
View File
@@ -25,7 +25,7 @@ class ParticipantCardDataService
/**
* Get card data for a single participant.
*
* @return array{name: string, roomName: string, price: string, isCanceled: bool}
* @return array{name: string, email: string, roomName: string, price: string, isCanceled: bool}
*/
public function getCardData(BookingDto $bookingDto, int $index): array
{
@@ -38,6 +38,9 @@ class ParticipantCardDataService
// Extract participant name with fallback
$name = $this->getParticipantName($participant, $index);
// Extract email
$email = $participant->email ?? '';
// Extract room name
$roomName = $this->getRoomName($bookingDto, $participant);
@@ -49,6 +52,7 @@ class ParticipantCardDataService
return [
'name' => $name,
'email' => $email,
'roomName' => $roomName,
'price' => $price,
'isCanceled' => $isCanceled,
@@ -58,7 +62,7 @@ class ParticipantCardDataService
/**
* Get card data for all participants.
*
* @return array<int, array{name: string, roomName: string, price: string, isCanceled: bool}>
* @return array<int, array{name: string, email: string, roomName: string, price: string, isCanceled: bool}>
*/
public function getAllCardsData(BookingDto $bookingDto): array
{
@@ -132,7 +136,7 @@ class ParticipantCardDataService
/**
* Get card data for a single participant with validation state.
*
* @return array{name: string, roomName: string, price: string, isCanceled: bool, isValid: bool, errorMessages: array<string>}
* @return array{name: string, email: string, roomName: string, price: string, isCanceled: bool, isValid: bool, errorMessages: array<string>}
*/
public function getCardDataWithValidation(BookingDto $bookingDto, int $index, array $validationGroups): array
{
@@ -171,7 +175,7 @@ class ParticipantCardDataService
/**
* Get card data for all participants with validation state.
*
* @return array<int, array{name: string, roomName: string, price: string, isCanceled: bool, isValid: bool, errorMessages: array<string>}>
* @return array<int, array{name: string, email: string, roomName: string, price: string, isCanceled: bool, isValid: bool, errorMessages: array<string>}>
*/
public function getAllCardsDataWithValidation(BookingDto $bookingDto, array $validationGroups): array
{
+28
View File
@@ -0,0 +1,28 @@
<?php
declare(strict_types=1);
namespace App\Twig;
use Twig\Extension\AbstractExtension;
use Twig\TwigFunction;
final class GravatarExtension extends AbstractExtension
{
public function getFunctions(): array
{
return [
new TwigFunction('gravatar_url', [$this, 'getGravatarUrl']),
];
}
/**
* Generates a Gravatar URL for the given email address.
*/
public function getGravatarUrl(string $email, int $size = 80): string
{
$hash = md5(strtolower(trim($email)));
return sprintf('https://www.gravatar.com/avatar/%s?s=%d&d=404', $hash, $size);
}
}