2 declare(strict_types = 1);
21 use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
22 use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
23 use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic;
24 use TYPO3Fluid\Fluid\Core\ViewHelper\ViewHelperVariableContainer;
25 use TYPO3Fluid\Fluid\View\Exception;
44 use CompileWithRenderStatic;
53 parent::initializeArguments();
54 $this->registerArgument(
'label',
'string',
'Label of the menu item',
true);
55 $this->registerArgument(
'uri',
'string',
'Action uri',
true);
67 \Closure $renderChildrenClosure,
68 RenderingContextInterface $renderingContext
70 $viewHelperVariableContainer = $renderingContext->getViewHelperVariableContainer();
74 $menu = $viewHelperVariableContainer->get(ModuleLayoutViewHelper::class, Menu::class);
75 $menuItem = $menu->makeMenuItem();
76 $menuItem->setTitle($arguments[
'label']);
77 $menuItem->setHref($arguments[
'uri']);
78 $menuItem->setActive(self::isCurrentUri($arguments[
'uri']));
79 $menu->addMenuItem($menuItem);
86 private static function ensureProperNesting(ViewHelperVariableContainer $viewHelperVariableContainer):
void
88 if (!$viewHelperVariableContainer->exists(ModuleLayoutViewHelper::class, Menu::class)) {
89 throw new Exception(sprintf(
'%s must be nested in <f.be.moduleLayout.menu> ViewHelper', self::class), 1531235592);
99 return GeneralUtility::getIndpEnv(
'REQUEST_URI') === $uri;