ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilComponentPluginLanguageUpdatedObjective.php
Go to the documentation of this file.
1<?php declare(strict_types=1);
2
3/* Copyright (c) 2021 Daniel Weise <daniel.weise@concepts-and-training.de> Extended GPL, see docs/LICENSE */
4
6use ILIAS\DI;
7
9{
10 protected $plugin_name;
11
12 public function __construct(string $plugin_name)
13 {
14 $this->plugin_name = $plugin_name;
15 }
16
20 public function getHash() : string
21 {
22 return hash("sha256", self::class . $this->plugin_name);
23 }
24
28 public function getLabel() : string
29 {
30 return "Update plugin language $this->plugin_name.";
31 }
32
36 public function isNotable() : bool
37 {
38 return true;
39 }
40
44 public function getPreconditions(Setup\Environment $environment) : array
45 {
46 return [
48 ];
49 }
50
54 public function achieve(Setup\Environment $environment) : Setup\Environment
55 {
56 list($ORIG_DIC, $ORIG_ilDB) = $this->initEnvironment($environment);
57
58 $plugin = $GLOBALS["DIC"]["ilPluginAdmin"]->getRawPluginDataFor($this->plugin_name);
59
61 $plugin['component_type'],
62 $plugin['component_name'],
63 $plugin['slot_id'],
64 $plugin['name']
65 );
66
67 $pl->updateLanguages();
68
69
70 $GLOBALS["DIC"] = $ORIG_DIC;
71 $GLOBALS["ilDB"] = $ORIG_ilDB;
72
73 return $environment;
74 }
75
79 public function isApplicable(Setup\Environment $environment) : bool
80 {
81 list($ORIG_DIC, $ORIG_ilDB) = $this->initEnvironment($environment);
82
83 $plugin = $GLOBALS["DIC"]["ilPluginAdmin"]->getRawPluginDataFor($this->plugin_name);
84
85 if (is_null($plugin) || !$plugin['supports_cli_setup']) {
86 return false;
87 }
88
89 $GLOBALS["DIC"] = $ORIG_DIC;
90 $GLOBALS["ilDB"] = $ORIG_ilDB;
91
92 return true;
93 }
94
95 protected function initEnvironment(Setup\Environment $environment) : array
96 {
97 $db = $environment->getResource(Setup\Environment::RESOURCE_DATABASE);
98 $plugin_admin = $environment->getResource(Setup\Environment::RESOURCE_PLUGIN_ADMIN);
99 $ini = $environment->getResource(Setup\Environment::RESOURCE_ILIAS_INI);
100 $client_ini = $environment->getResource(Setup\Environment::RESOURCE_CLIENT_INI);
101
102
103 // ATTENTION: This is a total abomination. It only exists to allow various
104 // sub components of the various readers to run. This is a memento to the
105 // fact, that dependency injection is something we want. Currently, every
106 // component could just service locate the whole world via the global $DIC.
107 $ORIG_DIC = $GLOBALS["DIC"];
108 $ORIG_ilDB = $GLOBALS["ilDB"];
109
110 $GLOBALS["DIC"] = new DI\Container();
111 $GLOBALS["DIC"]["ilDB"] = $db;
112 $GLOBALS["ilDB"] = $db;
113 $GLOBALS["DIC"]["ilIliasIniFile"] = $ini;
114 $GLOBALS["DIC"]["ilClientIniFile"] = $client_ini;
115 $GLOBALS["DIC"]["ilLogger"] = new class() extends ilLogger {
116 public function __construct()
117 {
118 }
119 public function isHandling($a_level)
120 {
121 return true;
122 }
123 public function log($a_message, $a_level = ilLogLevel::INFO)
124 {
125 }
126 public function dump($a_variable, $a_level = ilLogLevel::INFO)
127 {
128 }
129 public function debug($a_message, $a_context = array())
130 {
131 }
132 public function info($a_message)
133 {
134 }
135 public function notice($a_message)
136 {
137 }
138 public function warning($a_message)
139 {
140 }
141 public function error($a_message)
142 {
143 }
144 public function critical($a_message)
145 {
146 }
147 public function alert($a_message)
148 {
149 }
150 public function emergency($a_message)
151 {
152 }
153 public function write($a_message, $a_level = ilLogLevel::INFO)
154 {
155 }
156 public function writeLanguageLog($a_topic, $a_lang_key)
157 {
158 }
159 public function logStack($a_level = null, $a_message = '')
160 {
161 }
162 public function writeMemoryPeakUsage($a_level)
163 {
164 }
165 };
166 $GLOBALS["DIC"]["ilLog"] = new class() extends ilLog {
167 public function __construct()
168 {
169 }
170 public function write($m, $l = ilLogLevel::INFO)
171 {
172 }
173 public function info($msg)
174 {
175 }
176 public function warning($msg)
177 {
178 }
179 public function error($msg)
180 {
181 }
182 public function debug($msg, $a = [])
183 {
184 }
185 public function dump($msg, $a = ilLogLevel::INFO)
186 {
187 }
188 };
189 $GLOBALS["DIC"]["ilLoggerFactory"] = new class() extends ilLoggerFactory {
190 public function __construct()
191 {
192 }
193 public static function getRootLogger()
194 {
195 return $GLOBALS["DIC"]["ilLogger"];
196 }
197 public static function getLogger($a)
198 {
199 return $GLOBALS["DIC"]["ilLogger"];
200 }
201 };
202 $GLOBALS["ilLog"] = $GLOBALS["DIC"]["ilLog"];
203 $GLOBALS["DIC"]["ilBench"] = null;
204 $GLOBALS["DIC"]["lng"] = new ilLanguage('en');
205 $GLOBALS["DIC"]["ilPluginAdmin"] = $plugin_admin;
206 $GLOBALS["DIC"]["ilCtrl"] = new ilCtrl();
207 $GLOBALS["DIC"]["ilias"] = null;
208 $GLOBALS["DIC"]["ilErr"] = null;
209 $GLOBALS["DIC"]["tree"] = new class() extends ilTree {
210 public function __construct()
211 {
212 }
213 };
214 $GLOBALS["DIC"]["ilAppEventHandler"] = new class() extends ilAppEventHandler {
215 public function __construct()
216 {
217 }
218 public function raise($a_component, $a_event, $a_parameter = "") : void
219 {
220 }
221 };
222 $GLOBALS["DIC"]["ilObjDataCache"] = new ilObjectDataCache();
223 $GLOBALS["DIC"]["ilSetting"] = new ilSetting();
224 $GLOBALS["DIC"]["objDefinition"] = new ilObjectDefinition();
225 $GLOBALS["DIC"]["rbacadmin"] = new class() extends ilRbacAdmin {
226 public function __construct()
227 {
228 }
229 };
230 $GLOBALS["DIC"]["rbacreview"] = new class() extends ilRbacReview {
231 public function __construct()
232 {
233 }
234 };
235 $GLOBALS["DIC"]["ilUser"] = new class() extends ilObjUser {
236 public $prefs = [];
237
238 public function __construct()
239 {
240 $this->prefs["language"] = "en";
241 }
242 };
243
244 if (!defined('DEBUG')) {
245 define('DEBUG', false);
246 }
247
248 if (!defined("ILIAS_ABSOLUTE_PATH")) {
249 define("ILIAS_ABSOLUTE_PATH", dirname(__FILE__, 5));
250 }
251
252 if (!defined('SYSTEM_ROLE_ID')) {
253 define('SYSTEM_ROLE_ID', '2');
254 }
255
256 if (!defined("CLIENT_ID")) {
257 define('CLIENT_ID', $client_ini->readVariable('client', 'name'));
258 }
259
260 if (!defined("ILIAS_WEB_DIR")) {
261 define('ILIAS_WEB_DIR', dirname(__DIR__, 4) . "/data/");
262 }
263
264 return [$ORIG_DIC, $ORIG_ilDB];
265 }
266}
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
An exception for terminatinating execution or to throw for unit testing.
Customizing of pimple-DIC for ILIAS.
Definition: Container.php:19
error($a_errmsg)
set error message @access public
Global event handler.
This class provides processing control methods.
language handling
logging
Definition: class.ilLog.php:19
Component logger with individual log levels by component id.
class ilObjectDataCache
parses the objects.xml it handles the xml-description of all ilias objects
static getPluginObject(string $a_ctype, string $a_cname, string $a_slot_id, string $a_pname)
Class ilRbacAdmin Core functions for role based access control.
class ilRbacReview Contains Review functions of core Rbac.
ILIAS Setting Class.
Tree class data representation in hierachical trees using the Nested Set Model with Gaps by Joe Celco...
An environment holds resources to be used in the setup process.
Definition: Environment.php:12
An objective is a desired state of the system that is supposed to be created by the setup.
Definition: Objective.php:15
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...
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples
$ini
Definition: raiseError.php:4
info()
Definition: info.php:2