ILIAS  trunk Revision v11.0_alpha-1744-gb0451eebef4
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
UI.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
26 use ilLanguage;
28 
29 class UI
30 {
31  public function __construct(
32  private readonly string $id,
33  private readonly UIServices $services,
34  private readonly ilLanguage $language
35  ) {
36  }
37 
38  public function create(): UIFactory
39  {
40  return $this->services->factory();
41  }
42 
44  {
45  return $this->services->mainTemplate();
46  }
47 
48  public function loadLanguageModule(string $module): void
49  {
50  $this->language->loadLanguageModule($module);
51  }
52 
53  public function txt(string $name): string
54  {
55  $this->loadLanguageModule($this->id);
56  return $this->language->txt($this->firstExisting([
57  $this->id . '_' . $name,
58  ilObjLegalDocumentsGUI::TYPE . '_' . $name
59  ], $name));
60  }
61 
65  private function firstExisting(array $lang_vars, string $fallback): string
66  {
67  foreach ($lang_vars as $lang_var) {
68  if ($this->language->exists($lang_var)) {
69  return $lang_var;
70  }
71  }
72 
73  return $fallback;
74  }
75 }
__construct(private readonly string $id, private readonly UIServices $services, private readonly ilLanguage $language)
Definition: UI.php:31
firstExisting(array $lang_vars, string $fallback)
Definition: UI.php:65
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
loadLanguageModule(string $module)
Definition: UI.php:48
Provides fluid interface to RBAC services.
Definition: UIServices.php:24
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
language()
description: > Example for rendring a language glyph.
Definition: language.php:41