Skip to content

Commit

Permalink
Add TranslateViewHelper
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthias Richter committed Dec 4, 2024
1 parent bea92d4 commit eac067d
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions Classes/ViewHelpers/TranslateViewHelper.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php
declare(strict_types=1);
namespace Slub\LisztBibliography\ViewHelpers;

use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;

final class TranslateViewHelper extends AbstractViewHelper
{
public function initializeArguments(): void
{
$this->registerArgument('key', 'string', 'the key wich has to be translated', true);
}

public static function renderStatic(
array $arguments,
\Closure $renderChildrenClosure,
RenderingContextInterface $renderingContext)
: ?array
{
$extConf = GeneralUtility::makeInstance(ExtensionConfiguration::class)->get('liszt_bibliography');

return GeneralUtility::makeInstanceService(SearchService::class)->
get($arguments['key'], $extConf['elasticLocaleIndexName']);
}
}

0 comments on commit eac067d

Please sign in to comment.