‪TYPO3CMS  9.5
PageViewHelper.php
Go to the documentation of this file.
1 <?php
3 
4 /*
5  * This file is part of the TYPO3 CMS project.
6  *
7  * It is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License, either version 2
9  * of the License, or any later version.
10  *
11  * For the full copyright and license information, please read the
12  * LICENSE.txt file that was distributed with this source code.
13  *
14  * The TYPO3 project - inspiring people to share!
15  */
16 
17 use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
18 use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
19 use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic;
20 
60 class ‪PageViewHelper extends AbstractViewHelper
61 {
62  use CompileWithRenderStatic;
63 
67  public function ‪initializeArguments()
68  {
69  $this->registerArgument('pageUid', 'int', 'target PID');
70  $this->registerArgument('additionalParams', 'array', 'query parameters to be attached to the resulting URI', false, []);
71  $this->registerArgument('pageType', 'int', 'type of the target page. See typolink.parameter', false, 0);
72  $this->registerArgument('noCache', 'bool', 'set this to disable caching for the target page. You should not need this.', false, false);
73  $this->registerArgument('noCacheHash', 'bool', 'set this to suppress the cHash query parameter created by TypoLink. You should not need this.', false, false);
74  $this->registerArgument('section', 'string', 'the anchor to be added to the URI', false, '');
75  $this->registerArgument('linkAccessRestrictedPages', 'bool', 'If set, links pointing to access restricted pages will still link to the page even though the page cannot be accessed.', false, false);
76  $this->registerArgument('absolute', 'bool', 'If set, the URI of the rendered link is absolute', false, false);
77  $this->registerArgument('addQueryString', 'bool', 'If set, the current query parameters will be kept in the URI', false, false);
78  $this->registerArgument('argumentsToBeExcludedFromQueryString', 'array', 'arguments to be removed from the URI. Only active if $addQueryString = TRUE', false, []);
79  $this->registerArgument('addQueryStringMethod', 'string', 'Set which parameters will be kept. Only active if $addQueryString = TRUE');
80  }
81 
88  public static function ‪renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
89  {
90  $pageUid = $arguments['pageUid'];
91  $additionalParams = $arguments['additionalParams'];
92  $pageType = $arguments['pageType'];
93  $noCache = $arguments['noCache'];
94  $noCacheHash = $arguments['noCacheHash'];
95  $section = $arguments['section'];
96  $linkAccessRestrictedPages = $arguments['linkAccessRestrictedPages'];
97  $absolute = $arguments['absolute'];
98  $addQueryString = $arguments['addQueryString'];
99  $argumentsToBeExcludedFromQueryString = $arguments['argumentsToBeExcludedFromQueryString'];
100  $addQueryStringMethod = $arguments['addQueryStringMethod'];
101 
102  $uriBuilder = $renderingContext->getControllerContext()->getUriBuilder();
103  $uri = $uriBuilder->setTargetPageUid($pageUid)->setTargetPageType($pageType)->setNoCache($noCache)->setUseCacheHash(!$noCacheHash)->setSection($section)->setLinkAccessRestrictedPages($linkAccessRestrictedPages)->setArguments($additionalParams)->setCreateAbsoluteUri($absolute)->setAddQueryString($addQueryString)->setArgumentsToBeExcludedFromQueryString($argumentsToBeExcludedFromQueryString)->setAddQueryStringMethod($addQueryStringMethod)->build();
104  return $uri;
105  }
106 }
‪TYPO3\CMS\Fluid\ViewHelpers\Uri\PageViewHelper
Definition: PageViewHelper.php:61
‪TYPO3\CMS\Fluid\ViewHelpers\Uri\PageViewHelper\renderStatic
‪static string renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
Definition: PageViewHelper.php:87
‪TYPO3\CMS\Fluid\ViewHelpers\Uri
Definition: ActionViewHelper.php:2
‪TYPO3\CMS\Fluid\ViewHelpers\Uri\PageViewHelper\initializeArguments
‪initializeArguments()
Definition: PageViewHelper.php:66