48 lines
2.0 KiB
PHP
48 lines
2.0 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Twig;
|
|
|
|
use Twig\Extension\AbstractExtension;
|
|
use Twig\TwigFilter;
|
|
use Twig\TwigFunction;
|
|
|
|
/**
|
|
* Twig extension registering booking-related filters and functions.
|
|
*
|
|
* Provides filters for formatting (file_size, format_money, format_service_price)
|
|
* and mapping (map_gender, map_status, map_country, map_nationality), plus
|
|
* functions for field state checking and participant eligibility.
|
|
*/
|
|
class AppExtension extends AbstractExtension
|
|
{
|
|
public function getFilters(): array
|
|
{
|
|
return [
|
|
new TwigFilter('file_size', [AppRuntime::class, 'formatBytes']),
|
|
new TwigFilter('file_icon', [AppRuntime::class, 'fileIconFilter'], ['is_safe' => ['html']]),
|
|
new TwigFilter('format_money', [AppRuntime::class, 'formatMoney']),
|
|
new TwigFilter('format_service_price', [AppRuntime::class, 'formatServicePrice']),
|
|
new TwigFilter('map_gender', [AppRuntime::class, 'mapGender']),
|
|
new TwigFilter('map_status', [AppRuntime::class, 'mapStatus']),
|
|
new TwigFilter('map_country', [AppRuntime::class, 'mapCountry']),
|
|
new TwigFilter('map_nationality', [AppRuntime::class, 'mapNationality']),
|
|
];
|
|
}
|
|
|
|
public function getFunctions(): array
|
|
{
|
|
return [
|
|
new TwigFunction('is_participant_eligible', [AppRuntime::class, 'isParticipantEligible']),
|
|
new TwigFunction('qa_attribute', [AppRuntime::class, 'renderQaAttribute'], ['is_safe' => ['html']]),
|
|
new TwigFunction('is_static_text', [AppRuntime::class, 'isStaticText']),
|
|
new TwigFunction('is_hidden', [AppRuntime::class, 'isHidden']),
|
|
new TwigFunction('collect_invalid_field_labels', [AppRuntime::class, 'collectInvalidFieldLabels']),
|
|
new TwigFunction('booking_theme', [AppRuntime::class, 'getBookingTheme']),
|
|
new TwigFunction('gtm_id', [AppRuntime::class, 'getGtmId']),
|
|
new TwigFunction('cmp_url', [AppRuntime::class, 'getCmpUrl']),
|
|
];
|
|
}
|
|
}
|