* * * * Output:: * *
* *
*/ class ModuleLinkViewHelper extends AbstractViewHelper { use CompileWithRenderStatic; /** * Initializes the arguments */ public function initializeArguments() { $this->registerArgument('route', 'string', 'The route to link to', true); $this->registerArgument('arguments', 'array', 'Additional link arguments', false, []); $this->registerArgument('query', 'string', 'Additional link arguments as string'); $this->registerArgument('currentUrlParameterName', 'string', 'Add current url as given parameter'); } /** * Render module link with arguments * * @param array $arguments * @param \Closure $renderChildrenClosure * @param RenderingContextInterface $renderingContext * @return string */ public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext): string { $uriBuilder = GeneralUtility::makeInstance(UriBuilder::class); $parameters = $arguments['arguments']; if ($arguments['query'] !== null) { ArrayUtility::mergeRecursiveWithOverrule($parameters, GeneralUtility::explodeUrl2Array($arguments['query'])); } if ($arguments['currentUrlParameterName'] !== null) { $parameters[$arguments['currentUrlParameterName']] = GeneralUtility::getIndpEnv('REQUEST_URI'); } return (string)$uriBuilder->buildUriFromRoute($arguments['route'], $parameters); } }