taktik-nette
This commit is contained in:
45
app/UI/Accessory/LatteExtension.php
Normal file
45
app/UI/Accessory/LatteExtension.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user