Skip to content
Snippets Groups Projects
Commit ba36b893 authored by Markus Klein's avatar Markus Klein Committed by Stefan Bürk
Browse files

[TASK] Add language attribute to *.action viewhelpers

This supplements the other viewhelpers already equipped
with this attribute.

Resolves: #101775
Releases: main, 12.4, 11.5
Change-Id: Iadcdb1de591d9d9e56722623cacd1a5cf8fbe0af
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/80827


Tested-by: default avatarcore-ci <typo3@b13.com>
Tested-by: default avatarStefan Bürk <stefan@buerk.tech>
Reviewed-by: default avatarStefan Bürk <stefan@buerk.tech>
parent f2f79d95
Branches
Tags
No related merge requests found
...@@ -59,6 +59,7 @@ class ActionViewHelper extends AbstractTagBasedViewHelper ...@@ -59,6 +59,7 @@ class ActionViewHelper extends AbstractTagBasedViewHelper
$this->registerArgument('pageUid', 'int', 'Target page. See TypoLink destination'); $this->registerArgument('pageUid', 'int', 'Target page. See TypoLink destination');
$this->registerArgument('pageType', 'int', 'Type of the target page. See typolink.parameter'); $this->registerArgument('pageType', 'int', 'Type of the target page. See typolink.parameter');
$this->registerArgument('noCache', 'bool', 'Set this to disable caching for the target page. You should not need this.'); $this->registerArgument('noCache', 'bool', 'Set this to disable caching for the target page. You should not need this.');
$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);
$this->registerArgument('section', 'string', 'The anchor to be added to the URI'); $this->registerArgument('section', 'string', 'The anchor to be added to the URI');
$this->registerArgument('format', 'string', 'The requested format, e.g. ".html'); $this->registerArgument('format', 'string', 'The requested format, e.g. ".html');
$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.'); $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.');
...@@ -85,6 +86,7 @@ class ActionViewHelper extends AbstractTagBasedViewHelper ...@@ -85,6 +86,7 @@ class ActionViewHelper extends AbstractTagBasedViewHelper
$pageUid = (int)$this->arguments['pageUid'] ?: null; $pageUid = (int)$this->arguments['pageUid'] ?: null;
$pageType = (int)($this->arguments['pageType'] ?? 0); $pageType = (int)($this->arguments['pageType'] ?? 0);
$noCache = (bool)($this->arguments['noCache'] ?? false); $noCache = (bool)($this->arguments['noCache'] ?? false);
$language = $this->arguments['language'] ?? null;
$section = (string)$this->arguments['section']; $section = (string)$this->arguments['section'];
$format = (string)$this->arguments['format']; $format = (string)$this->arguments['format'];
$linkAccessRestrictedPages = (bool)($this->arguments['linkAccessRestrictedPages'] ?? false); $linkAccessRestrictedPages = (bool)($this->arguments['linkAccessRestrictedPages'] ?? false);
...@@ -98,6 +100,7 @@ class ActionViewHelper extends AbstractTagBasedViewHelper ...@@ -98,6 +100,7 @@ class ActionViewHelper extends AbstractTagBasedViewHelper
->reset() ->reset()
->setTargetPageType($pageType) ->setTargetPageType($pageType)
->setNoCache($noCache) ->setNoCache($noCache)
->setLanguage($language)
->setSection($section) ->setSection($section)
->setFormat($format) ->setFormat($format)
->setLinkAccessRestrictedPages($linkAccessRestrictedPages) ->setLinkAccessRestrictedPages($linkAccessRestrictedPages)
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
namespace TYPO3\CMS\Fluid\ViewHelpers\Uri; namespace TYPO3\CMS\Fluid\ViewHelpers\Uri;
use TYPO3\CMS\Extbase\Mvc\Web\Routing\UriBuilder;
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface; use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper; use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic; use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic;
...@@ -50,6 +51,7 @@ class ActionViewHelper extends AbstractViewHelper ...@@ -50,6 +51,7 @@ class ActionViewHelper extends AbstractViewHelper
$this->registerArgument('pageUid', 'int', 'Target page. See TypoLink destination'); $this->registerArgument('pageUid', 'int', 'Target page. See TypoLink destination');
$this->registerArgument('pageType', 'int', 'Type of the target page. See typolink.parameter', false, 0); $this->registerArgument('pageType', 'int', 'Type of the target page. See typolink.parameter', false, 0);
$this->registerArgument('noCache', 'bool', 'Set this to disable caching for the target page. You should not need this.', false, null); $this->registerArgument('noCache', 'bool', 'Set this to disable caching for the target page. You should not need this.', false, null);
$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);
$this->registerArgument('section', 'string', 'The anchor to be added to the URI', false, ''); $this->registerArgument('section', 'string', 'The anchor to be added to the URI', false, '');
$this->registerArgument('format', 'string', 'The requested format, e.g. ".html', false, ''); $this->registerArgument('format', 'string', 'The requested format, e.g. ".html', false, '');
$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); $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);
...@@ -77,6 +79,8 @@ class ActionViewHelper extends AbstractViewHelper ...@@ -77,6 +79,8 @@ class ActionViewHelper extends AbstractViewHelper
$pageType = (int)($arguments['pageType'] ?? 0); $pageType = (int)($arguments['pageType'] ?? 0);
/** @var bool $noCache */ /** @var bool $noCache */
$noCache = (bool)($arguments['noCache'] ?? false); $noCache = (bool)($arguments['noCache'] ?? false);
/** @var string|null $language */
$language = $arguments['language'] ?? null;
/** @var string|null $section */ /** @var string|null $section */
$section = $arguments['section'] ?? null; $section = $arguments['section'] ?? null;
/** @var string|null $format */ /** @var string|null $format */
...@@ -102,6 +106,7 @@ class ActionViewHelper extends AbstractViewHelper ...@@ -102,6 +106,7 @@ class ActionViewHelper extends AbstractViewHelper
/** @var array|null $arguments */ /** @var array|null $arguments */
$arguments = $arguments['arguments'] ?? []; $arguments = $arguments['arguments'] ?? [];
/** @var UriBuilder $uriBuilder */
$uriBuilder = $renderingContext->getUriBuilder(); $uriBuilder = $renderingContext->getUriBuilder();
$uriBuilder->reset(); $uriBuilder->reset();
...@@ -145,6 +150,8 @@ class ActionViewHelper extends AbstractViewHelper ...@@ -145,6 +150,8 @@ class ActionViewHelper extends AbstractViewHelper
$uriBuilder->setLinkAccessRestrictedPages(true); $uriBuilder->setLinkAccessRestrictedPages(true);
} }
$uriBuilder->setLanguage($language);
return $uriBuilder->uriFor($action, $arguments, $controller, $extensionName, $pluginName); return $uriBuilder->uriFor($action, $arguments, $controller, $extensionName, $pluginName);
} }
} }
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment