ILIAS  trunk Revision v11.0_alpha-1861-g09f3d197f78
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
Translations.php
Go to the documentation of this file.
1 <?php
2 
20 
22 {
26  private array $translations = [];
27 
28  public function __construct(
29  private readonly string $default_language_code,
30  private readonly TranslatableItem $item,
31  Translation ...$translations
32  ) {
33  foreach ($translations as $translation) {
34  $this->add($translation);
35  }
36  }
37 
38  public function getId(): string
39  {
40  return $this->item->getId();
41  }
42 
43  public function get(): array
44  {
45  return $this->translations;
46  }
47 
48  public function add(Translation $translation): void
49  {
50  $this->translations[$translation->getLanguageCode()] = $translation;
51  }
52 
53  public function remove(string $language_code): void
54  {
55  unset($this->translations[$language_code]);
56  }
57 
58  public function getLanguageCode(string $language_code): ?Translation
59  {
60  return $this->translations[$language_code] ?? null;
61  }
62 
63  public function getDefault(): ?Translation
64  {
65  return $this->translations[$this->default_language_code] ?? null;
66  }
67 
68  public function getLanguageKeys(): array
69  {
70  return array_keys($this->translations);
71  }
72 
73 }
__construct(private readonly string $default_language_code, private readonly TranslatableItem $item, Translation ... $translations)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null