ILIAS  release_8 Revision v8.24
class.ilPluginLanguageUpdatedObjective.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21use ILIAS\Setup;
22use ILIAS\DI;
23
25{
26 protected string $plugin_name;
27
28 public function __construct(string $plugin_name)
29 {
30 $this->plugin_name = $plugin_name;
31 }
32
36 public function getHash(): string
37 {
38 return hash("sha256", self::class . $this->plugin_name);
39 }
40
44 public function getLabel(): string
45 {
46 return "Update plugin language $this->plugin_name.";
47 }
48
52 public function isNotable(): bool
53 {
54 return true;
55 }
56
60 public function getPreconditions(Setup\Environment $environment): array
61 {
62 return [
63 new \ilIniFilesLoadedObjective(),
64 new \ilDatabaseInitializedObjective(),
67 ];
68 }
69
73 public function achieve(Setup\Environment $environment): Setup\Environment
74 {
75 $component_repository = $environment->getResource(Setup\Environment::RESOURCE_COMPONENT_REPOSITORY);
76 [$ORIG_DIC, $ORIG_ilDB] = $this->initEnvironment($environment, $component_repository);
77
78 $plugin = $component_repository->getPluginByName($this->plugin_name);
79 $language_handler = new ilPluginLanguage($plugin);
80 $language_handler->updateLanguages();
81
82 $GLOBALS["DIC"] = $ORIG_DIC;
83 $GLOBALS["ilDB"] = $ORIG_ilDB;
84
85 return $environment;
86 }
87
91 public function isApplicable(Setup\Environment $environment): bool
92 {
93 $component_repository = $environment->getResource(Setup\Environment::RESOURCE_COMPONENT_REPOSITORY);
94
95 return $component_repository->getPluginByName($this->plugin_name)->supportsCLISetup();
96 }
97
98 protected function initEnvironment(Setup\Environment $environment, \ilComponentRepository $component_repository): array
99 {
100 $db = $environment->getResource(Setup\Environment::RESOURCE_DATABASE);
101 $ini = $environment->getResource(Setup\Environment::RESOURCE_ILIAS_INI);
102 $client_ini = $environment->getResource(Setup\Environment::RESOURCE_CLIENT_INI);
103 $component_factory = $environment->getResource(Setup\Environment::RESOURCE_COMPONENT_FACTORY);
104
105
106 // ATTENTION: This is a total abomination. It only exists to allow various
107 // sub components of the various readers to run. This is a memento to the
108 // fact, that dependency injection is something we want. Currently, every
109 // component could just service locate the whole world via the global $DIC.
110 $ORIG_DIC = $GLOBALS["DIC"];
111 $ORIG_ilDB = $GLOBALS["ilDB"];
112
113 $GLOBALS["DIC"] = new DI\Container();
114 $GLOBALS["DIC"]["ilDB"] = $db;
115 $GLOBALS["ilDB"] = $db;
116 $GLOBALS["DIC"]["ilIliasIniFile"] = $ini;
117 $GLOBALS["DIC"]["ilClientIniFile"] = $client_ini;
118 $GLOBALS["DIC"]["component.factory"] = $component_factory;
119 $GLOBALS["DIC"]["ilLog"] = new class () extends ilLogger {
120 public function __construct()
121 {
122 }
123 public function isHandling(int $a_level): bool
124 {
125 return true;
126 }
127 public function log(string $a_message, int $a_level = ilLogLevel::INFO): void
128 {
129 }
130 public function dump($a_variable, int $a_level = ilLogLevel::INFO): void
131 {
132 }
133 public function debug(string $a_message, array $a_context = array()): void
134 {
135 }
136 public function info(string $a_message): void
137 {
138 }
139 public function notice(string $a_message): void
140 {
141 }
142 public function warning(string $a_message): void
143 {
144 }
145 public function error(string $a_message): void
146 {
147 }
148 public function critical(string $a_message): void
149 {
150 }
151 public function alert(string $a_message): void
152 {
153 }
154 public function emergency(string $a_message): void
155 {
156 }
157 public function write(string $a_message, $a_level = ilLogLevel::INFO): void
158 {
159 }
160 public function writeLanguageLog(string $a_topic, string $a_lang_key): void
161 {
162 }
163 public function logStack(?int $a_level = null, string $a_message = ''): void
164 {
165 }
166 public function writeMemoryPeakUsage(int $a_level): void
167 {
168 }
169 };
170 $GLOBALS["DIC"]["ilLoggerFactory"] = new class () extends ilLoggerFactory {
171 public function __construct()
172 {
173 }
174 public static function getRootLogger(): ilLogger
175 {
176 return $GLOBALS["DIC"]["ilLog"];
177 }
178 public static function getLogger(string $a_component_id): ilLogger
179 {
180 return $GLOBALS["DIC"]["ilLog"];
181 }
182 };
183 $GLOBALS["ilLog"] = $GLOBALS["DIC"]["ilLog"];
184 $GLOBALS["DIC"]["ilBench"] = null;
185 $GLOBALS["DIC"]["lng"] = new ilLanguage('en');
186 $GLOBALS["DIC"]["lng"]->lang_user = "en";
187 $GLOBALS["DIC"]["ilias"] = null;
188 $GLOBALS["DIC"]["ilErr"] = null;
189 $GLOBALS["DIC"]["tree"] = new class () extends ilTree {
190 public function __construct()
191 {
192 }
193 };
194 $GLOBALS["DIC"]["ilAppEventHandler"] = new class () extends ilAppEventHandler {
195 public function __construct()
196 {
197 }
198 public function raise($a_component, $a_event, $a_parameter = ""): void
199 {
200 }
201 };
202 $GLOBALS["DIC"]["ilObjDataCache"] = new ilObjectDataCache();
203 $GLOBALS["DIC"]["ilSetting"] = new ilSetting();
204 $GLOBALS["DIC"]["component.repository"] = $component_repository;
205 $GLOBALS["DIC"]["objDefinition"] = new ilObjectDefinition();
206 $GLOBALS["DIC"]["rbacadmin"] = new class () extends ilRbacAdmin {
207 public function __construct()
208 {
209 }
210 };
211 $GLOBALS["DIC"]["rbacreview"] = new class () extends ilRbacReview {
212 public function __construct()
213 {
214 }
215 };
216 $GLOBALS["DIC"]["ilUser"] = new class () extends ilObjUser {
217 public function __construct()
218 {
219 $this->prefs["language"] = "en";
220 }
221 };
222
223 if (!defined('DEBUG')) {
224 define('DEBUG', false);
225 }
226
227 if (!defined("ILIAS_ABSOLUTE_PATH")) {
228 define("ILIAS_ABSOLUTE_PATH", dirname(__FILE__, 5));
229 }
230
231 if (!defined('SYSTEM_ROLE_ID')) {
232 define('SYSTEM_ROLE_ID', '2');
233 }
234
235 if (!defined("CLIENT_ID")) {
236 define('CLIENT_ID', $client_ini->readVariable('client', 'name'));
237 }
238
239 if (!defined("ILIAS_WEB_DIR")) {
240 define('ILIAS_WEB_DIR', dirname(__DIR__, 4) . "/data/");
241 }
242
243 return [$ORIG_DIC, $ORIG_ilDB];
244 }
245}
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
Customizing of pimple-DIC for ILIAS.
Definition: Container.php:32
error(string $a_errmsg)
Global event handler.
language handling
Component logger with individual log levels by component id.
User class.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
parses the objects.xml it handles the xml-description of all ilias objects
initEnvironment(Setup\Environment $environment, \ilComponentRepository $component_repository)
isApplicable(Setup\Environment $environment)
@inheritDoc
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class ilRbacAdmin Core functions for role based access control.
class ilRbacReview Contains Review functions of core Rbac.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
An environment holds resources to be used in the setup process.
Definition: Environment.php:28
getResource(string $id)
Consumers of this method should check if the result is what they expect, e.g.
An objective is a desired state of the system that is supposed to be created by the setup.
Definition: Objective.php:31
Readable part of repository interface to ilComponentDataDB.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: Container.php:19
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$ini
Definition: raiseError.php:4