‪TYPO3CMS  11.5
PageViewHelper.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of the TYPO3 CMS project.
5  *
6  * It is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU General Public License, either version 2
8  * of the License, or any later version.
9  *
10  * For the full copyright and license information, please read the
11  * LICENSE.txt file that was distributed with this source code.
12  *
13  * The TYPO3 project - inspiring people to share!
14  */
15 
17 
19 use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
20 use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
21 use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic;
22 
62 class ‪PageViewHelper extends AbstractViewHelper
63 {
64  use CompileWithRenderStatic;
65 
69  public function ‪initializeArguments()
70  {
71  $this->registerArgument('pageUid', 'int', 'target PID');
72  $this->registerArgument('additionalParams', 'array', 'query parameters to be attached to the resulting URI', false, []);
73  $this->registerArgument('pageType', 'int', 'type of the target page. See typolink.parameter', false, 0);
74  $this->registerArgument('noCache', 'bool', 'set this to disable caching for the target page. You should not need this.', false, false);
75  $this->registerArgument('language', 'string', 'link to a specific language - defaults to the current language, use a language ID or "current" to enforce a specific language', false, null);
76  $this->registerArgument('section', 'string', 'the anchor to be added to the URI', false, '');
77  $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);
78  $this->registerArgument('absolute', 'bool', 'If set, the URI of the rendered link is absolute', false, false);
79  $this->registerArgument('addQueryString', 'bool', 'If set, the current query parameters will be kept in the URI', false, false);
80  $this->registerArgument('argumentsToBeExcludedFromQueryString', 'array', 'arguments to be removed from the URI. Only active if $addQueryString = TRUE', false, []);
81  $this->registerArgument('addQueryStringMethod', 'string', 'This argument is not evaluated anymore and will be removed in TYPO3 v12.');
82  }
83 
90  public static function ‪renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
91  {
92  if (isset($arguments['addQueryStringMethod'])) {
93  trigger_error('Using the argument "addQueryStringMethod" in <f:uri.page> ViewHelper has no effect anymore and will be removed in TYPO3 v12. Remove the argument in your fluid template, as it will result in a fatal error.', E_USER_DEPRECATED);
94  }
95  $pageUid = $arguments['pageUid'];
96  $additionalParams = $arguments['additionalParams'];
97  $pageType = (int)($arguments['pageType'] ?? 0);
98  $noCache = $arguments['noCache'];
99  $section = $arguments['section'];
100  $language = $arguments['language'] ?? null;
101  $linkAccessRestrictedPages = $arguments['linkAccessRestrictedPages'];
102  $absolute = $arguments['absolute'];
103  $addQueryString = $arguments['addQueryString'];
104  $argumentsToBeExcludedFromQueryString = $arguments['argumentsToBeExcludedFromQueryString'];
105 
106  $uriBuilder = $renderingContext->getUriBuilder();
107  $uri = $uriBuilder
108  ->reset()
109  ->setTargetPageType($pageType)
110  ->setNoCache($noCache)
111  ->setSection($section)
112  ->setLanguage($language)
113  ->setLinkAccessRestrictedPages($linkAccessRestrictedPages)
114  ->setArguments($additionalParams)
115  ->setCreateAbsoluteUri($absolute)
116  ->setAddQueryString($addQueryString)
117  ->setArgumentsToBeExcludedFromQueryString($argumentsToBeExcludedFromQueryString)
118  ;
119 
121  $uriBuilder->setTargetPageUid((int)$pageUid);
122  }
123 
124  return $uri->build();
125  }
126 }
‪TYPO3\CMS\Core\Utility\MathUtility\canBeInterpretedAsInteger
‪static bool canBeInterpretedAsInteger($var)
Definition: MathUtility.php:74
‪TYPO3\CMS\Fluid\ViewHelpers\Uri\PageViewHelper
Definition: PageViewHelper.php:63
‪TYPO3\CMS\Fluid\ViewHelpers\Uri\PageViewHelper\renderStatic
‪static string renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
Definition: PageViewHelper.php:89
‪TYPO3\CMS\Fluid\ViewHelpers\Uri
Definition: ActionViewHelper.php:16
‪TYPO3\CMS\Core\Utility\MathUtility
Definition: MathUtility.php:22
‪TYPO3\CMS\Fluid\ViewHelpers\Uri\PageViewHelper\initializeArguments
‪initializeArguments()
Definition: PageViewHelper.php:68