ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
ILIAS\ILIASObject\Properties\Translations\Language Class Reference
+ Collaboration diagram for ILIAS\ILIASObject\Properties\Translations\Language:

Public Member Functions

 __construct (private readonly string $language_code, private string $title, private string $description, private bool $default=false, private bool $base=false)
 
 getLanguageCode ()
 
 getTitle ()
 
 withTitle (string $title)
 
 getDescription ()
 
 withDescription (string $description)
 
 isDefault ()
 
 withDefault (bool $default)
 
 isBase ()
 
 withBase (bool $base)
 
 toForm (\ilLanguage $language, FieldFactory $field_factory, Refinery $refinery)
 
 toRow (DataRowBuilder $row_builder, SystemLanguage $lng)
 
 getDisplayValueForKey (SystemLanguage $lng, string $key)
 

Data Fields

const KEY_LANGUAGE = 'language'
 
const KEY_BASE = 'base'
 
const KEY_DEFAULT = 'default'
 
const KEY_TITLE = 'title'
 
const KEY_DESCRIPTION = 'description'
 

Private Member Functions

 getTranslatedLanguageName (SystemLanguage $lng, string $language_code)
 

Detailed Description

Definition at line 29 of file Language.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\ILIASObject\Properties\Translations\Language::__construct ( private readonly string  $language_code,
private string  $title,
private string  $description,
private bool  $default = false,
private bool  $base = false 
)

Definition at line 37 of file Language.php.

43 {
44 }

Member Function Documentation

◆ getDescription()

ILIAS\ILIASObject\Properties\Translations\Language::getDescription ( )

Definition at line 63 of file Language.php.

63 : string
64 {
65 return $this->description;
66 }

Referenced by ILIAS\TestQuestionPool\ExportImport\Foundation\Normalize\Normalizer\IlObjectNormalizer\normalizeTranslations().

+ Here is the caller graph for this function:

◆ getDisplayValueForKey()

ILIAS\ILIASObject\Properties\Translations\Language::getDisplayValueForKey ( SystemLanguage  $lng,
string  $key 
)

Definition at line 145 of file Language.php.

148 : string|bool {
149 return match($key) {
150 self::KEY_LANGUAGE => $this->getTranslatedLanguageName(
151 $lng,
152 $this->language_code
153 ),
154 self::KEY_BASE => $this->base,
155 self::KEY_DEFAULT => $this->default,
156 self::KEY_TITLE => $this->title,
157 self::KEY_DESCRIPTION => $this->description
158 };
159 }
getTranslatedLanguageName(SystemLanguage $lng, string $language_code)
Definition: Language.php:161
global $lng
Definition: privfeed.php:26

References $lng.

◆ getLanguageCode()

ILIAS\ILIASObject\Properties\Translations\Language::getLanguageCode ( )

Definition at line 46 of file Language.php.

46 : string
47 {
48 return $this->language_code;
49 }

Referenced by ILIAS\TestQuestionPool\ExportImport\Foundation\Normalize\Normalizer\IlObjectNormalizer\normalizeTranslations(), and ILIAS\ILIASObject\Properties\Translations\Translations\withLanguage().

+ Here is the caller graph for this function:

◆ getTitle()

ILIAS\ILIASObject\Properties\Translations\Language::getTitle ( )

Definition at line 51 of file Language.php.

51 : string
52 {
53 return $this->title;
54 }

Referenced by ILIAS\TestQuestionPool\ExportImport\Foundation\Normalize\Normalizer\IlObjectNormalizer\normalizeTranslations().

+ Here is the caller graph for this function:

◆ getTranslatedLanguageName()

ILIAS\ILIASObject\Properties\Translations\Language::getTranslatedLanguageName ( SystemLanguage  $lng,
string  $language_code 
)
private

Definition at line 161 of file Language.php.

164 : string {
165 return $lng->txt("meta_l_{$language_code}");
166 }

◆ isBase()

ILIAS\ILIASObject\Properties\Translations\Language::isBase ( )

Definition at line 87 of file Language.php.

87 : bool
88 {
89 return $this->base;
90 }

Referenced by ILIAS\ILIASObject\Properties\Translations\Translations\withLanguage().

+ Here is the caller graph for this function:

◆ isDefault()

ILIAS\ILIASObject\Properties\Translations\Language::isDefault ( )

Definition at line 75 of file Language.php.

75 : bool
76 {
77 return $this->default;
78 }

Referenced by ILIAS\ILIASObject\Properties\Translations\Translations\withLanguage().

+ Here is the caller graph for this function:

◆ toForm()

ILIAS\ILIASObject\Properties\Translations\Language::toForm ( \ilLanguage  $language,
FieldFactory  $field_factory,
Refinery  $refinery 
)

Definition at line 99 of file Language.php.

103 : array {
104 return [
105 $field_factory->group([
106 self::KEY_LANGUAGE => $field_factory->hidden()->withValue($this->language_code),
107 self::KEY_TITLE => $field_factory->text($language->txt('title'))
108 ->withRequired(true)
109 ->withValue($this->title),
110 self::KEY_DESCRIPTION => $field_factory->textarea($language->txt('description'))
111 ->withValue($this->description),
112 self::KEY_DEFAULT => $field_factory->hidden()->withValue($this->isDefault()),
113 self::KEY_BASE => $field_factory->hidden()->withValue($this->isBase()),
114 ])->withAdditionalTransformation(
115 $refinery->custom()->transformation(
116 static fn(array $vs): self => new self(
117 $vs[self::KEY_LANGUAGE],
118 $vs[self::KEY_TITLE],
119 $vs[self::KEY_DESCRIPTION],
120 $vs[self::KEY_DEFAULT] === '1',
121 $vs[self::KEY_BASE] === '1'
122 )
123 )
124 )
125 ];
126 }

◆ toRow()

ILIAS\ILIASObject\Properties\Translations\Language::toRow ( DataRowBuilder  $row_builder,
SystemLanguage  $lng 
)

Definition at line 128 of file Language.php.

131 : DataRow {
132 return $row_builder->buildDataRow(
133 $this->language_code,
134 [
135 self::KEY_LANGUAGE => $this->getTranslatedLanguageName($lng, $this->language_code),
136 self::KEY_BASE => $this->isBase(),
137 self::KEY_DEFAULT => $this->isDefault(),
138 self::KEY_TITLE => $this->getTitle(),
139 self::KEY_DESCRIPTION => $this->getDescription()
140 ]
141 )->withDisabledAction(TranslationsTable::ACTION_DELETE, $this->isBase() || $this->isDefault())
142 ->withDisabledAction(TranslationsTable::ACTION_MAKE_DEFAULT, $this->isDefault());
143 }
buildDataRow(string $id, array $record)

◆ withBase()

ILIAS\ILIASObject\Properties\Translations\Language::withBase ( bool  $base)

Definition at line 92 of file Language.php.

92 : self
93 {
94 $clone = clone $this;
95 $clone->base = $base;
96 return $clone;
97 }

Referenced by ILIAS\ILIASObject\Properties\Translations\Translations\withLanguage().

+ Here is the caller graph for this function:

◆ withDefault()

ILIAS\ILIASObject\Properties\Translations\Language::withDefault ( bool  $default)

Definition at line 80 of file Language.php.

80 : self
81 {
82 $clone = clone $this;
83 $clone->default = $default;
84 return $clone;
85 }

◆ withDescription()

ILIAS\ILIASObject\Properties\Translations\Language::withDescription ( string  $description)

Definition at line 68 of file Language.php.

68 : self
69 {
70 $clone = clone $this;
71 $clone->description = $description;
72 return $clone;
73 }

◆ withTitle()

ILIAS\ILIASObject\Properties\Translations\Language::withTitle ( string  $title)

Definition at line 56 of file Language.php.

56 : self
57 {
58 $clone = clone $this;
59 $clone->title = $title;
60 return $clone;
61 }

Field Documentation

◆ KEY_BASE

const ILIAS\ILIASObject\Properties\Translations\Language::KEY_BASE = 'base'

Definition at line 32 of file Language.php.

◆ KEY_DEFAULT

const ILIAS\ILIASObject\Properties\Translations\Language::KEY_DEFAULT = 'default'

Definition at line 33 of file Language.php.

◆ KEY_DESCRIPTION

const ILIAS\ILIASObject\Properties\Translations\Language::KEY_DESCRIPTION = 'description'

Definition at line 35 of file Language.php.

◆ KEY_LANGUAGE

const ILIAS\ILIASObject\Properties\Translations\Language::KEY_LANGUAGE = 'language'

Definition at line 31 of file Language.php.

◆ KEY_TITLE

const ILIAS\ILIASObject\Properties\Translations\Language::KEY_TITLE = 'title'

Definition at line 34 of file Language.php.


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