Files
myep-team/src/Twig/AppExtension.php
T

42 lines
2.1 KiB
PHP

<?php
namespace App\Twig;
use Twig\Extension\AbstractExtension;
use Twig\TwigFilter;
use Twig\TwigFunction;
class AppExtension extends AbstractExtension
{
public function getFilters(): array
{
return [
new TwigFilter('nl2list', [AppRuntime::class, 'nl2List'], ['is_safe' => ['html']]),
new TwigFilter('file_size', [AppRuntime::class, 'formatBytes']),
new TwigFilter('file_icon', [AppRuntime::class, 'fileIconFilter'], ['is_safe' => ['html']]),
new TwigFilter('date_diff', [AppRuntime::class, 'dateDiffForHumans']),
new TwigFilter('format_money', [AppRuntime::class, 'formatMoney']),
new TwigFilter('format_rating', [AppRuntime::class, 'formatRating'], ['is_safe' => ['html']]),
new TwigFilter('license_label', [AppRuntime::class, 'licenseLabel']),
new TwigFilter('teamer_status_label', [AppRuntime::class, 'teamerStatusLabel']),
new TwigFilter('bpn_country_label', [AppRuntime::class, 'bpnCountryLabel']),
new TwigFilter('bpn_pickup_label', [AppRuntime::class, 'bpnPickupLabel']),
new TwigFilter('upload_status_badge', [AppRuntime::class, 'renderUploadStatusBadge'], ['is_safe' => ['html']]),
new TwigFilter('upload_filename_full', [AppRuntime::class, 'getFilenameWithFolder']),
];
}
public function getFunctions(): array
{
return [
new TwigFunction('icon', [AppRuntime::class, 'renderIcon'], ['needs_environment' => true, 'is_safe' => ['html']]),
new TwigFunction('is_current_route', [AppRuntime::class, 'isCurrentRoute']),
new TwigFunction('is_maintenance_mode', [AppRuntime::class, 'isMaintenanceMode']),
new TwigFunction('return_url', [AppRuntime::class, 'getEncodedReturnUrl']),
new TwigFunction('forwarded_return_url', [AppRuntime::class, 'getForwardedReturnUrl']),
new TwigFunction('qa_attribute', [AppRuntime::class, 'renderQaAttribute'], ['is_safe' => ['html']]),
new TwigFunction('has_pickup', [AppRuntime::class, 'hasPickup']),
];
}
}