This commit is contained in:
Björn Fromme
2025-02-27 19:21:12 +01:00
parent f5d3619c4a
commit ac498f9040
15 changed files with 311 additions and 185 deletions
+37 -2
View File
@@ -2,14 +2,17 @@
namespace App\Twig;
use App\BusProNet\DataProvider\CountryDataProvider;
use Twig\Environment;
use Twig\Extension\RuntimeExtensionInterface;
use Twig\Extra\Intl\IntlExtension;
class AppRuntime implements RuntimeExtensionInterface
{
public function __construct(private readonly IntlExtension $intlExtension)
{
public function __construct(
private readonly IntlExtension $intlExtension,
private readonly CountryDataProvider $countryDataProvider,
) {
}
public function fileIconFilter(Environment $environment, string $mimeType, ?string $classes = 'w-4 h-4'): string
@@ -50,6 +53,8 @@ class AppRuntime implements RuntimeExtensionInterface
public function mapStatus(string $status): string
{
$status = strtoupper($status);
return match ($status) {
'F', 'F/S' => 'Festbuchung',
'S' => 'Stornierung',
@@ -58,4 +63,34 @@ class AppRuntime implements RuntimeExtensionInterface
default => '',
};
}
public function mapGender(string $gender): string
{
$gender = strtoupper($gender);
return match ($gender) {
'M' => 'männlich',
'F' => 'weiblich',
'D' => 'divers',
default => '',
};
}
public function mapCountry(?string $country): ?string
{
if (null === $country) {
return null;
}
return $this->countryDataProvider->get($country)?->name;
}
public function mapNationality(?string $nationality): ?string
{
if (null === $nationality) {
return null;
}
return $this->countryDataProvider->get($nationality)?->nationality;
}
}