46 lines
883 B
PHP
46 lines
883 B
PHP
<?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);
|
|
}
|
|
}
|