20 use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
21 use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
22 use TYPO3Fluid\Fluid\Core\ViewHelper\Exception;
23 use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic;
77 use CompileWithRenderStatic;
91 $this->registerArgument(
'parameter',
'string',
'stdWrap.typolink style parameter string',
true);
92 $this->registerArgument(
'target',
'string',
'',
false,
'');
93 $this->registerArgument(
'class',
'string',
'',
false,
'');
94 $this->registerArgument(
'title',
'string',
'',
false,
'');
95 $this->registerArgument(
'additionalParams',
'string',
'',
false,
'');
96 $this->registerArgument(
'additionalAttributes',
'array',
'',
false, []);
97 $this->registerArgument(
'useCacheHash',
'bool',
'',
false,
false);
98 $this->registerArgument(
'addQueryString',
'bool',
'',
false,
false);
99 $this->registerArgument(
'addQueryStringMethod',
'string',
'',
false,
'GET');
100 $this->registerArgument(
'addQueryStringExclude',
'string',
'',
false,
'');
101 $this->registerArgument(
'absolute',
'bool',
'Ensure the resulting URL is an absolute URL',
false,
false);
114 public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
116 $parameter = $arguments[
'parameter'] ??
'';
117 $target = $arguments[
'target'] ??
'';
118 $class = $arguments[
'class'] ??
'';
119 $title = $arguments[
'title'] ??
'';
120 $additionalParams = $arguments[
'additionalParams'] ??
'';
121 $additionalAttributes = $arguments[
'additionalAttributes'] ?? [];
122 $useCacheHash = $arguments[
'useCacheHash'] ??
false;
123 $addQueryString = $arguments[
'addQueryString'] ??
false;
124 $addQueryStringMethod = $arguments[
'addQueryStringMethod'] ??
'GET';
125 $addQueryStringExclude = $arguments[
'addQueryStringExclude'] ??
'';
126 $absolute = $arguments[
'absolute'] ??
false;
132 $extraAttributes = [];
133 foreach ($additionalAttributes as $attributeName => $attributeValue) {
134 $extraAttributes[] = $attributeName .
'="' . htmlspecialchars($attributeValue) .
'"';
136 $aTagParams = implode(
' ', $extraAttributes);
139 $content = (string)$renderChildrenClosure();
143 $contentObject = GeneralUtility::makeInstance(ContentObjectRenderer::class);
144 $contentObject->start([],
'');
145 $content = $contentObject->stdWrap(
149 'parameter' => $typolinkParameter,
150 'ATagParams' => $aTagParams,
151 'useCacheHash' => $useCacheHash,
152 'addQueryString' => $addQueryString,
153 'addQueryString.' => [
154 'method' => $addQueryStringMethod,
155 'exclude' => $addQueryStringExclude
157 'forceAbsoluteUrl' => $absolute
179 $typoLinkCodec = GeneralUtility::makeInstance(TypoLinkCodecService::class);
180 $typolinkConfiguration = $typoLinkCodec->decode($parameter);
181 if (empty($typolinkConfiguration)) {
182 return $typolinkConfiguration;
187 $typolinkConfiguration[
'target'] = $target;
192 $classes = explode(
' ', trim($typolinkConfiguration[
'class']) .
' ' . trim($class));
193 $typolinkConfiguration[
'class'] = implode(
' ', array_unique(array_filter($classes)));
198 $typolinkConfiguration[
'title'] = $title;
202 if ($additionalParams) {
203 $typolinkConfiguration[
'additionalParams'] .= $additionalParams;
206 return $typoLinkCodec->encode($typolinkConfiguration);