Skip to content

Commit

Permalink
[TASK] Add language attribute to *.action viewhelpers
Browse files Browse the repository at this point in the history
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/+/80836
Reviewed-by: Stefan Bürk <stefan@buerk.tech>
Tested-by: Stefan Bürk <stefan@buerk.tech>
Tested-by: core-ci <typo3@b13.com>
  • Loading branch information
liayn authored and sbuerk committed Sep 3, 2023
1 parent c4f6c2c commit 55fe867
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
Expand Up @@ -62,6 +62,7 @@ public function initializeArguments(): void
$this->registerArgument('pageUid', 'int', 'Target page. See TypoLink destination');
$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('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('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.');
Expand Down Expand Up @@ -91,6 +92,7 @@ public function render(): string
$pageUid = (int)$this->arguments['pageUid'] ?: null;
$pageType = (int)($this->arguments['pageType'] ?? 0);
$noCache = (bool)($this->arguments['noCache'] ?? false);
$language = $this->arguments['language'] ?? null;
$section = (string)$this->arguments['section'];
$format = (string)$this->arguments['format'];
$linkAccessRestrictedPages = (bool)($this->arguments['linkAccessRestrictedPages'] ?? false);
Expand All @@ -106,6 +108,7 @@ public function render(): string
->setRequest($request)
->setTargetPageType($pageType)
->setNoCache($noCache)
->setLanguage($language)
->setSection($section)
->setFormat($format)
->setLinkAccessRestrictedPages($linkAccessRestrictedPages)
Expand Down
Expand Up @@ -53,6 +53,7 @@ public function initializeArguments(): void
$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('noCache', 'bool', 'Set this to disable caching for the target page. You should not need this.', false);
$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('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);
Expand All @@ -76,6 +77,7 @@ public static function renderStatic(array $arguments, \Closure $renderChildrenCl
$pageUid = (int)($arguments['pageUid'] ?? 0);
$pageType = (int)($arguments['pageType'] ?? 0);
$noCache = (bool)($arguments['noCache'] ?? false);
$language = $arguments['language'] ?? null;
/** @var string|null $section */
$section = $arguments['section'] ?? null;
/** @var string|null $format */
Expand All @@ -99,6 +101,7 @@ public static function renderStatic(array $arguments, \Closure $renderChildrenCl
/** @var array|null $arguments */
$arguments = $arguments['arguments'] ?? [];

/** @var UriBuilder $uriBuilder */
$uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
$uriBuilder->reset()->setRequest($request);

Expand Down Expand Up @@ -133,6 +136,8 @@ public static function renderStatic(array $arguments, \Closure $renderChildrenCl
$uriBuilder->setLinkAccessRestrictedPages(true);
}

$uriBuilder->setLanguage($language);

return $uriBuilder->uriFor($action, $arguments, $controller, $extensionName, $pluginName);
}
}

0 comments on commit 55fe867

Please sign in to comment.