FluidTYPO3\Vhs\ViewHelpers\Menu\SubViewHelper::render PHP Method

render() public method

public render ( ) : null | string
return null | string
    public function render()
    {
        $pageUid = $this->arguments['pageUid'];
        $parentInstance = $this->retrieveReconfiguredParentMenuInstance($pageUid);
        if (null === $parentInstance) {
            return null;
        }
        $parentArguments = $parentInstance->getArguments();
        $isActive = $this->pageService->isActive($pageUid);
        // Note about next case: although $isCurrent in most cases implies $isActive, cases where the menu item
        // that is being rendered is in fact the current page but is NOT part of the rootline of the menu being
        // rendered - which is expected for example if using a page setting to render a different page in menus.
        // This means that the following check although it appears redundant, it is in fact not.
        $isCurrent = $this->pageService->isCurrent($pageUid);
        $isExpanded = (bool) (true === (bool) $parentArguments['expandAll']);
        $shouldRender = (bool) (true === $isActive || true === $isCurrent || true === $isExpanded);
        if (false === $shouldRender) {
            return null;
        }
        // retrieve the set of template variables which were in play when the parent menu VH started rendering.
        $variables = $this->viewHelperVariableContainer->get(AbstractMenuViewHelper::class, 'variables');
        $parentInstance->setOriginal(false);
        $content = $parentInstance->render();
        // restore the previous set of variables after they most likely have changed during the render() above.
        foreach ($variables as $name => $value) {
            if (true === $this->templateVariableContainer->exists($name)) {
                $this->templateVariableContainer->remove($name);
                $this->templateVariableContainer->add($name, $value);
            }
        }
        return $content;
    }