46 lines
883 B
PHP
Raw Permalink Normal View History

2025-01-22 22:52:26 +01:00
<?php
declare(strict_types=1);
namespace App\UI\Accessory;
use Latte\Extension;
use Nette\Localization\Translator;
final class LatteExtension extends Extension
{
public function __construct(
private readonly Translator $translator
) {
}
public function getFilters(): array
{
return [];
}
public function getFunctions(): array
{
return [
'interests' => [$this, 'renderInterests'],
];
}
public function renderInterests(?string $interests): string
{
if ($interests === null) {
return '';
}
$explodedInterests = explode(',', $interests);
$rtVal = [];
foreach ($explodedInterests as $interest) {
$rtVal[] = $this->translator->translate('survey.interests.' . $interest);
}
return implode(',', $rtVal);
}
}