Ermögliche Rückgabe aller möglichen Sprachoptionen in Verbindung mit den vom Nutzer freigeschalteten.

This commit is contained in:
Marcel Diegelmann 2025-11-05 14:37:38 +01:00
parent a8b3dce899
commit 8c139fbe04

View file

@ -60,7 +60,7 @@ class DataSourceSynonymRowType extends AbstractType
'required' => true,
// Restrict to languages configured in the language menu: disable ChoiceLoader and provide explicit choices
'choice_loader' => null,
'choices' => $this->buildLocaleChoices(),
'choices' => $this->buildLocaleChoices(true),
'preferred_choices' => $this->getPreferredLocales(),
'constraints' => [
new Assert\NotBlank(message: 'settings.system.data_source_synonyms.row_type.value_not_blank'),
@ -97,9 +97,14 @@ class DataSourceSynonymRowType extends AbstractType
* Returns only locales configured in the language menu (settings) or falls back to the parameter.
* Format: ['German (DE)' => 'de', ...]
*/
private function buildLocaleChoices(): array
private function buildLocaleChoices(bool $returnPossible = false): array
{
$locales = $this->getPreferredLocales();
if ($returnPossible) {
$locales = $this->getPossibleLocales();
}
$choices = [];
foreach ($locales as $code) {
$label = Locales::getName($code);
@ -119,6 +124,11 @@ class DataSourceSynonymRowType extends AbstractType
return !empty($fromSettings) ? array_values($fromSettings) : array_values($this->preferredLanguagesParam);
}
private function getPossibleLocales(): array
{
return array_values($this->preferredLanguagesParam);
}
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setRequired('data_sources');