17 use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
18 use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
19 use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic;
37 use CompileWithRenderStatic;
44 $this->registerArgument(
'useCacheHash',
'bool',
'True whether the cache hash should be appended to the URL',
false,
false);
45 $this->registerArgument(
'addQueryStringMethod',
'string',
'Method to be used for query string');
46 $this->registerArgument(
'action',
'string',
'Target action');
47 $this->registerArgument(
'arguments',
'array',
'Arguments',
false, []);
48 $this->registerArgument(
'section',
'string',
'The anchor to be added to the URI',
false,
'');
49 $this->registerArgument(
'format',
'string',
'The requested format, e.g. ".html',
false,
'');
50 $this->registerArgument(
'ajax',
'bool',
'TRUE if the URI should be to an AJAX widget, FALSE otherwise.',
false,
false);
59 public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
61 $ajax = $arguments[
'ajax'];
64 return static::getAjaxUri($renderingContext, $arguments);
66 return static::getWidgetUri($renderingContext, $arguments);
76 protected static function getAjaxUri(RenderingContextInterface $renderingContext, array $arguments)
78 $controllerContext = $renderingContext->getControllerContext();
79 $action = $arguments[
'action'];
80 $arguments = $arguments[
'arguments'];
81 if ($action ===
null) {
82 $action = $controllerContext->getRequest()->getControllerActionName();
86 $arguments[
'type'] = 7076;
87 $arguments[
'fluid-widget-id'] = $controllerContext->getRequest()->getWidgetContext()->getAjaxWidgetIdentifier();
88 $arguments[
'action'] = $action;
89 return '?' . http_build_query($arguments,
null,
'&');
99 protected static function getWidgetUri(RenderingContextInterface $renderingContext, array $arguments)
101 $controllerContext = $renderingContext->getControllerContext();
102 $uriBuilder = $controllerContext->getUriBuilder();
103 $argumentPrefix = $controllerContext->getRequest()->getArgumentPrefix();
104 $parameters = $arguments[
'arguments'] ?? [];
105 if ($arguments[
'action'] ??
false) {
106 $parameters[
'action'] = $arguments[
'action'];
108 if (($arguments[
'format'] ??
'') !==
'') {
109 $parameters[
'format'] = $arguments[
'format'];
111 return $uriBuilder->reset()
112 ->setArguments([$argumentPrefix => $parameters])
113 ->setSection($arguments[
'section'])
114 ->setUseCacheHash($arguments[
'useCacheHash'])
115 ->setAddQueryString(
true)
116 ->setAddQueryStringMethod($arguments[
'addQueryStringMethod'])
117 ->setArgumentsToBeExcludedFromQueryString([$argumentPrefix,
'cHash'])
118 ->setFormat($arguments[
'format'])