[UTIL][FormFields] Allow specifying a null actor in the language field, for when there isn't a logged in user
This commit is contained in:
parent
6b38972cca
commit
e62896b84e
|
@ -150,9 +150,12 @@ class Language extends Entity
|
|||
* Get all the available languages as well as the languages $actor
|
||||
* prefers and are appropriate for posting in/to $context_actor
|
||||
*/
|
||||
public static function getSortedLanguageChoices(Actor $actor, ?Actor $context_actor, ?bool $use_short_display): array
|
||||
public static function getSortedLanguageChoices(?Actor $actor, ?Actor $context_actor, ?bool $use_short_display): array
|
||||
{
|
||||
$language_choices = self::getLanguageChoices();
|
||||
$language_choices = self::getLanguageChoices();
|
||||
if (\is_null($actor)) {
|
||||
return [$language_choices, []];
|
||||
}
|
||||
$preferred_language_choices = $actor->getPreferredLanguageChoices($context_actor);
|
||||
ksort($language_choices);
|
||||
if ($use_short_display ?? Common::config('posting', 'use_short_language_display')) {
|
||||
|
|
|
@ -80,7 +80,7 @@ abstract class FormFields
|
|||
/**
|
||||
* Create a from field for `select`ing a language for $actor, in reply or related to $context_actor
|
||||
*/
|
||||
public static function language(Actor $actor, ?Actor $context_actor, string $label, ?string $help = null, bool $multiple = false, bool $required = true, ?bool $use_short_display = null, ?string $form_id = null, bool $use_no_selection = false): array
|
||||
public static function language(?Actor $actor, ?Actor $context_actor, string $label, ?string $help = null, bool $multiple = false, bool $required = true, ?bool $use_short_display = null, ?string $form_id = null, bool $use_no_selection = false): array
|
||||
{
|
||||
[$language_choices, $preferred_language_choices] = Language::getSortedLanguageChoices($actor, $context_actor, use_short_display: $use_short_display);
|
||||
if ($use_no_selection) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user