TYPO3 CMS  TYPO3_7-6
TypolinkViewHelper.php
Go to the documentation of this file.
1 <?php
3 
4 /* *
5  * This script is part of the TYPO3 project - inspiring people to share! *
6  * *
7  * TYPO3 is free software; you can redistribute it and/or modify it under *
8  * the terms of the GNU General Public License version 2 as published by *
9  * the Free Software Foundation. *
10  * *
11  * This script is distributed in the hope that it will be useful, but *
12  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- *
13  * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General *
14  * Public License for more details. *
15  * */
16 
23 
50 {
59  public function render($parameter, $additionalParams = '')
60  {
61  return static::renderStatic(
62  [
63  'parameter' => $parameter,
64  'additionalParams' => $additionalParams
65  ],
67  $this->renderingContext
68  );
69  }
70 
79  {
80  $parameter = $arguments['parameter'];
81  $additionalParams = $arguments['additionalParams'];
82 
83  $content = '';
84  if ($parameter) {
85  $contentObject = GeneralUtility::makeInstance(ContentObjectRenderer::class);
86  $content = $contentObject->typoLink_URL(
87  [
88  'parameter' => self::createTypolinkParameterArrayFromArguments($parameter, $additionalParams),
89  ]
90  );
91  }
92 
93  return $content;
94  }
95 
104  protected static function createTypolinkParameterArrayFromArguments($parameter, $additionalParameters = '')
105  {
106  $typoLinkCodec = GeneralUtility::makeInstance(TypoLinkCodecService::class);
107  $typolinkConfiguration = $typoLinkCodec->decode($parameter);
108  if (empty($typolinkConfiguration)) {
109  return $typolinkConfiguration;
110  }
111 
112  // Combine additionalParams
113  if ($additionalParameters) {
114  $typolinkConfiguration['additionalParams'] .= $additionalParameters;
115  }
116 
117  return $typoLinkCodec->encode($typolinkConfiguration);
118  }
119 }