57 lines
1.7 KiB
PHP
Executable File
57 lines
1.7 KiB
PHP
Executable File
<?php
|
|
|
|
/*
|
|
* This file is developed by evoWeb.
|
|
*
|
|
* It is free software; you can redistribute it and/or modify it under
|
|
* the terms of the GNU General Public License, either version 2
|
|
* of the License, or any later version.
|
|
*
|
|
* For the full copyright and license information, please read the
|
|
* LICENSE.txt file that was distributed with this source code.
|
|
*/
|
|
|
|
namespace Evoweb\EwBase\ViewHelpers;
|
|
|
|
use TYPO3\CMS\Core\Crypto\HashService;
|
|
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
|
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
|
|
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
|
|
use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic;
|
|
|
|
class HashViewHelper extends AbstractViewHelper
|
|
{
|
|
use CompileWithRenderStatic;
|
|
|
|
/**
|
|
* @var bool
|
|
*/
|
|
protected $escapeOutput = false;
|
|
|
|
public function initializeArguments(): void
|
|
{
|
|
parent::initializeArguments();
|
|
$this->registerArgument('action', 'string', 'Target action');
|
|
$this->registerArgument('arguments', 'array', 'Arguments for the controller action, associative array');
|
|
}
|
|
|
|
public static function renderStatic(
|
|
array $arguments,
|
|
\Closure $renderChildrenClosure,
|
|
RenderingContextInterface $renderingContext
|
|
): string {
|
|
$result = '';
|
|
if (
|
|
$arguments['action'] !== null
|
|
&& $arguments['arguments'] !== null
|
|
&& isset($arguments['arguments']['user'])
|
|
) {
|
|
/** @var HashService $hashService */
|
|
$hashService = GeneralUtility::makeInstance(HashService::class);
|
|
$result = $hashService->hmac($arguments['action'] . '::' . $arguments['arguments']['user'], '');
|
|
}
|
|
|
|
return $result;
|
|
}
|
|
}
|