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

fix default for Request::i18n() if only one language is configured, fixes #4811

Closes #4811

Merge request studip/studip!3604
parent 8ac7666c
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 I18NString|null $default default value if parameter is not set * @param I18NString|string|null $default default value if parameter is not set
* @param callable|null $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(string $param, ?I18NString $default = NULL, Callable $op = null) public static function i18n(string $param, $default = null, Callable $op = null)
{ {
$value = self::get($param, $default ? $default->original() : null); $value = self::get($param, $default instanceof I18NString ? $default->original() : $default);
if (isset($value)) { if (isset($value)) {
$lang = self::getArray($param . '_i18n') ?: ($default ? $default->toArray() : []); $lang = self::getArray($param . '_i18n') ?: ($default instanceof I18NString ? $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