Skip to content
Snippets Groups Projects
Commit 60903cff authored by Jan-Hendrik Willms's avatar Jan-Hendrik Willms
Browse files

fix default handling of Request::i18n(), fixes #4774

Closes #4774

Merge request studip/studip!3566
parent 66319771
No related branches found
No related tags found
No related merge requests found
...@@ -191,18 +191,18 @@ class Request implements ArrayAccess, IteratorAggregate ...@@ -191,18 +191,18 @@ class Request implements ArrayAccess, IteratorAggregate
/** /**
* Return the value of the selected query parameter as an I18NString. * Return the value of the selected query parameter as an I18NString.
* *
* @param string $param parameter name * @param string $param parameter name
* @param string $default default value if parameter is not set * @param I18NString|null $default default value if parameter is not set
* @param Callable $op Operation to perform on each text string * @param callable|null $op Operation to perform on each text string
* *
* @return I18NString parameter value as string (if set), else NULL * @return I18NString parameter value as string (if set), else NULL
*/ */
public static function i18n($param, $default = NULL, Callable $op = null) public static function i18n(string $param, ?I18NString $default = NULL, Callable $op = null)
{ {
$value = self::get($param, $default); $value = self::get($param, $default ? $default->original() : null);
if (isset($value)) { if (isset($value)) {
$lang = self::getArray($param . '_i18n'); $lang = self::getArray($param . '_i18n') ?: ($default ? $default->toArray() : []);
if ($op) { if ($op) {
$value = $op($value); $value = $op($value);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment