ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ILIAS\LegalDocuments\Condition\Definition\UserLanguageDefinition Class Reference
+ Inheritance diagram for ILIAS\LegalDocuments\Condition\Definition\UserLanguageDefinition:
+ Collaboration diagram for ILIAS\LegalDocuments\Condition\Definition\UserLanguageDefinition:

Public Member Functions

 __construct (private readonly UI $ui, private readonly array $installed_languages, private readonly Closure $required)
 
 formGroup (array $arguments=[])
 
 withCriterion (CriterionContent $criterion)
 
 translatedType ()
 
 translatedLanguage (string $language)
 
 formGroup (array $arguments=[])
 
 withCriterion (CriterionContent $criterion)
 
 translatedType ()
 

Private Member Functions

 radio (string $lang_key, array $options, $value)
 

Detailed Description

Definition at line 33 of file UserLanguageDefinition.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\LegalDocuments\Condition\Definition\UserLanguageDefinition::__construct ( private readonly UI  $ui,
private readonly array  $installed_languages,
private readonly Closure  $required 
)
Parameters
list<string>$installed_languages
Closure(array<string,mixed>)Constraint $required

Definition at line 39 of file UserLanguageDefinition.php.

43 {
44 }

Member Function Documentation

◆ formGroup()

ILIAS\LegalDocuments\Condition\Definition\UserLanguageDefinition::formGroup ( array  $arguments = [])

Implements ILIAS\LegalDocuments\ConditionDefinition.

Definition at line 46 of file UserLanguageDefinition.php.

46 : Group
47 {
48 $languages = array_combine($this->installed_languages, array_map($this->translatedLanguage(...), $this->installed_languages));
49
50 return $this->ui->create()->input()->field()->group([
51 'lng' => $this->radio(
52 $this->ui->txt('language'),
53 $languages,
54 $arguments['lng'] ?? null
55 )->withRequired(true, ($this->required)($languages))
56 ], $this->ui->txt('crit_type_usr_language'), $this->ui->txt('crit_type_usr_language_info'));
57 }

References ILIAS\LegalDocuments\Condition\Definition\UserLanguageDefinition\radio(), ILIAS\LegalDocuments\Condition\Definition\UserLanguageDefinition\translatedLanguage(), and ILIAS\Repository\ui().

+ Here is the call graph for this function:

◆ radio()

ILIAS\LegalDocuments\Condition\Definition\UserLanguageDefinition::radio ( string  $lang_key,
array  $options,
  $value 
)
private
Parameters
array<string,string>$options
null | string | int$value

Definition at line 78 of file UserLanguageDefinition.php.

78 : Radio
79 {
80 $field = $this->ui->create()->input()->field()->radio($lang_key);
81 foreach ($options as $key => $label) {
82 $field = $field->withOption((string) $key, $label);
83 }
84
85 return $value !== null && isset($options[(string) $value]) ? $field->withValue((string) $value) : $field;
86 }

References ILIAS\Repository\ui().

Referenced by ILIAS\LegalDocuments\Condition\Definition\UserLanguageDefinition\formGroup().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ translatedLanguage()

ILIAS\LegalDocuments\Condition\Definition\UserLanguageDefinition::translatedLanguage ( string  $language)

Definition at line 69 of file UserLanguageDefinition.php.

69 : string
70 {
71 return $this->ui->txt('meta_l_' . $language);
72 }

References ILIAS\Repository\ui().

Referenced by ILIAS\LegalDocuments\Condition\Definition\UserLanguageDefinition\formGroup().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ translatedType()

ILIAS\LegalDocuments\Condition\Definition\UserLanguageDefinition::translatedType ( )

Implements ILIAS\LegalDocuments\ConditionDefinition.

Definition at line 64 of file UserLanguageDefinition.php.

64 : string
65 {
66 return $this->ui->txt('crit_type_usr_language');
67 }

References ILIAS\Repository\ui().

+ Here is the call graph for this function:

◆ withCriterion()

ILIAS\LegalDocuments\Condition\Definition\UserLanguageDefinition::withCriterion ( CriterionContent  $criterion)

Implements ILIAS\LegalDocuments\ConditionDefinition.

Definition at line 59 of file UserLanguageDefinition.php.

59 : Condition
60 {
61 return new UserLanguage($criterion, $this, $this->ui);
62 }

References ILIAS\Repository\ui().

+ Here is the call graph for this function:

The documentation for this class was generated from the following file: