ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
Translations.php
Go to the documentation of this file.
1<?php
2
20
26{
30 private array $translations = [];
31
32 public function __construct(
33 private readonly string $default_language_code,
34 private readonly TranslatableItem $item,
36 ) {
37 foreach ($translations as $translation) {
38 $this->add($translation);
39 }
40 }
41
42 public function getId(): string
43 {
44 return $this->item->getId();
45 }
46
47 public function get(): array
48 {
50 }
51
52 public function add(Translation $translation): void
53 {
54 $this->translations[$translation->getLanguageCode()] = $translation;
55 }
56
57 public function remove(string $language_code): void
58 {
59 unset($this->translations[$language_code]);
60 }
61
62 public function getLanguageCode(string $language_code): ?Translation
63 {
64 return $this->translations[$language_code] ?? null;
65 }
66
67 public function getDefault(): ?Translation
68 {
69 return $this->translations[$this->default_language_code] ?? null;
70 }
71
72 public function getLanguageKeys(): array
73 {
74 return array_keys($this->translations);
75 }
76
77}
__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...