FluidTYPO3\Vhs\ViewHelpers\Page\LinkViewHelper::render PHP Метод

render() публичный Метод

Render method
public render ( ) : null | string
Результат null | string
    public function render()
    {
        // Check if link wizard link
        $pageUid = $this->arguments['pageUid'];
        $additionalParameters = (array) $this->arguments['additionalParams'];
        if (false === is_numeric($pageUid)) {
            $linkConfig = GeneralUtility::unQuoteFilenames($pageUid, true);
            if (true === isset($linkConfig[0])) {
                $pageUid = $linkConfig[0];
            }
            if (true === isset($linkConfig[1]) && '-' !== $linkConfig[1]) {
                $this->tag->addAttribute('target', $linkConfig[1]);
            }
            if (true === isset($linkConfig[2]) && '-' !== $linkConfig[2]) {
                $this->tag->addAttribute('class', $linkConfig[2]);
            }
            if (true === isset($linkConfig[3]) && '-' !== $linkConfig[3]) {
                $this->tag->addAttribute('title', $linkConfig[3]);
            }
            if (true === isset($linkConfig[4]) && '-' !== $linkConfig[4]) {
                $additionalParametersString = trim($linkConfig[4], '&');
                $additionalParametersArray = GeneralUtility::trimExplode('&', $additionalParametersString);
                foreach ($additionalParametersArray as $parameter) {
                    list($key, $value) = GeneralUtility::trimExplode('=', $parameter);
                    $additionalParameters[$key] = $value;
                }
            }
        }
        // Get page via pageUid argument or current id
        $pageUid = (int) $pageUid;
        if (0 === $pageUid) {
            $pageUid = $GLOBALS['TSFE']->id;
        }
        $showAccessProtected = (bool) $this->arguments['showAccessProtected'];
        //TODO: Remove handling of deprecated argument
        if ($this->hasArgument('linkAccessRestrictedPages')) {
            $showAccessProtected = (bool) $this->arguments['linkAccessRestrictedPages'];
        }
        $page = $this->pageService->getPage($pageUid, $showAccessProtected);
        if (empty($page)) {
            return null;
        }
        $targetPage = $this->pageService->getShortcutTargetPage($page);
        if ($targetPage !== null) {
            if ($this->pageService->shouldUseShortcutTarget($this->arguments)) {
                $page = $targetPage;
            }
            if ($this->pageService->shouldUseShortcutUid($this->arguments)) {
                $pageUid = $targetPage['uid'];
            }
        }
        // Do not render the link, if the page should be hidden
        $currentLanguageUid = $GLOBALS['TSFE']->sys_language_uid;
        $hidePage = $this->pageService->hidePageForLanguageUid($page, $currentLanguageUid);
        if (true === $hidePage) {
            return null;
        }
        // Get the title from the page or page overlay
        $title = $this->getTitleValue($page);
        // Check if we should assign page title to the template variable container
        $pageTitleAs = $this->arguments['pageTitleAs'];
        if (!empty($pageTitleAs)) {
            $variables = [$pageTitleAs => $title];
        } else {
            $variables = [];
        }
        // Render children to see if an alternative title content should be used
        $renderedTitle = $this->renderChildrenWithVariables($variables);
        if (!empty($renderedTitle)) {
            $title = $renderedTitle;
        }
        $class = [];
        if ($showAccessProtected && $this->pageService->isAccessProtected($page)) {
            $class[] = $this->arguments['classAccessProtected'];
        }
        if ($showAccessProtected && $this->pageService->isAccessGranted($page)) {
            $class[] = $this->arguments['classAccessGranted'];
        }
        $additionalCssClasses = implode(' ', $class);
        $uriBuilder = $this->controllerContext->getUriBuilder();
        $uri = $uriBuilder->reset()->setTargetPageUid($pageUid)->setTargetPageType($this->arguments['pageType'])->setNoCache($this->arguments['noCache'])->setUseCacheHash(!$this->arguments['noCacheHash'])->setSection($this->arguments['section'])->setArguments($additionalParameters)->setCreateAbsoluteUri($this->arguments['absolute'])->setAddQueryString($this->arguments['addQueryString'])->setArgumentsToBeExcludedFromQueryString((array) $this->arguments['argumentsToBeExcludedFromQueryString'])->build();
        $this->tag->addAttribute('href', $uri);
        if (!empty($this->arguments['class'])) {
            $this->tag->addAttribute('class', $this->arguments['class'] . ' ' . $additionalCssClasses);
        } else {
            $this->tag->addAttribute('class', $additionalCssClasses);
        }
        $this->tag->setContent($title);
        return $this->tag->render();
    }