TYPO3 CMS  TYPO3_8-7
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 
47 {
51  protected $tagName = 'a';
52 
56  public function initializeArguments()
57  {
58  parent::initializeArguments();
60  $this->registerTagAttribute('target', 'string', 'Target of link', false);
61  $this->registerTagAttribute('rel', 'string', 'Specifies the relationship between the current document and the linked document', false);
62  }
63 
78  public function render($pageUid = null, array $additionalParams = [], $pageType = 0, $noCache = false, $noCacheHash = false, $section = '', $linkAccessRestrictedPages = false, $absolute = false, $addQueryString = false, array $argumentsToBeExcludedFromQueryString = [], $addQueryStringMethod = null)
79  {
80  $uriBuilder = $this->renderingContext->getControllerContext()->getUriBuilder();
81  $uri = $uriBuilder->reset()
82  ->setTargetPageUid($pageUid)
83  ->setTargetPageType($pageType)
84  ->setNoCache($noCache)
85  ->setUseCacheHash(!$noCacheHash)
86  ->setSection($section)
87  ->setLinkAccessRestrictedPages($linkAccessRestrictedPages)
88  ->setArguments($additionalParams)
89  ->setCreateAbsoluteUri($absolute)
90  ->setAddQueryString($addQueryString)
91  ->setArgumentsToBeExcludedFromQueryString($argumentsToBeExcludedFromQueryString)
92  ->setAddQueryStringMethod($addQueryStringMethod)
93  ->build();
94  if ((string)$uri !== '') {
95  $this->tag->addAttribute('href', $uri);
96  $this->tag->setContent($this->renderChildren());
97  $this->tag->forceClosingTag(true);
98  $result = $this->tag->render();
99  } else {
100  $result = $this->renderChildren();
101  }
102  return $result;
103  }
104 }
registerTagAttribute($name, $type, $description, $required=false, $default=null)