ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilComponentUpdatePluginObjective.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 2020 Daniel Weise <daniel.weise@concepts-and-training.de> Extended GPL, see docs/LICENSE */
3
4declare(strict_types=1);
5
7use ILIAS\DI;
9
11{
15 protected $plugin_name;
16
17 public function __construct(string $plugin_name)
18 {
19 $this->plugin_name = $plugin_name;
20 }
21
25 public function getHash() : string
26 {
27 return hash("sha256", self::class . $this->plugin_name);
28 }
29
33 public function getLabel() : string
34 {
35 return "Update plugin $this->plugin_name.";
36 }
37
41 public function isNotable() : bool
42 {
43 return true;
44 }
45
49 public function getPreconditions(Setup\Environment $environment) : array
50 {
51 return [
53 new \ilIniFilesLoadedObjective(),
54 new \ilDatabaseInitializedObjective(),
55 new \ilComponentPluginAdminInitObjective()
56 ];
57 }
58
62 public function achieve(Setup\Environment $environment) : Setup\Environment
63 {
64 list($ORIG_DIC, $ORIG_ilDB) = $this->initEnvironment($environment);
65
66 $plugin = $GLOBALS["DIC"]["ilPluginAdmin"]->getRawPluginDataFor($this->plugin_name);
67
68 if (!is_null($plugin) && $plugin['needs_update'] && $plugin['supports_cli_setup']) {
70 $plugin['component_type'],
71 $plugin['component_name'],
72 $plugin['slot_id'],
73 $plugin['name']
74 );
75
76 $pl->update();
77 }
78
79 $GLOBALS["DIC"] = $ORIG_DIC;
80 $GLOBALS["ilDB"] = $ORIG_ilDB;
81
82 return $environment;
83 }
84
88 public function isApplicable(Setup\Environment $environment) : bool
89 {
90 list($ORIG_DIC, $ORIG_ilDB) = $this->initEnvironment($environment);
91
92 $plugin = $GLOBALS["DIC"]["ilPluginAdmin"]->getRawPluginDataFor($this->plugin_name);
93
94 if (is_null($plugin) || !$plugin['supports_cli_setup']) {
95 return false;
96 }
97
98 $GLOBALS["DIC"] = $ORIG_DIC;
99 $GLOBALS["ilDB"] = $ORIG_ilDB;
100
101 return $plugin['needs_update'];
102 }
103
104 protected function initEnvironment(Setup\Environment $environment) : array
105 {
106 $db = $environment->getResource(Setup\Environment::RESOURCE_DATABASE);
107 $plugin_admin = $environment->getResource(Setup\Environment::RESOURCE_PLUGIN_ADMIN);
108 $ini = $environment->getResource(Setup\Environment::RESOURCE_ILIAS_INI);
109 $client_ini = $environment->getResource(Setup\Environment::RESOURCE_CLIENT_INI);
110
111
112 // ATTENTION: This is a total abomination. It only exists to allow various
113 // sub components of the various readers to run. This is a memento to the
114 // fact, that dependency injection is something we want. Currently, every
115 // component could just service locate the whole world via the global $DIC.
116 $ORIG_DIC = $GLOBALS["DIC"];
117 $ORIG_ilDB = $GLOBALS["ilDB"];
118
119 $GLOBALS["DIC"] = new DI\Container();
120 $GLOBALS["DIC"]["ilDB"] = $db;
121 $GLOBALS["ilDB"] = $db;
122 $GLOBALS["DIC"]["ilIliasIniFile"] = $ini;
123 $GLOBALS["DIC"]["ilClientIniFile"] = $client_ini;
124 $GLOBALS["DIC"]["ilLogger"] = new class() extends ilLogger {
125 public function __construct()
126 {
127 }
128 public function isHandling($a_level)
129 {
130 return true;
131 }
132 public function log($a_message, $a_level = ilLogLevel::INFO)
133 {
134 }
135 public function dump($a_variable, $a_level = ilLogLevel::INFO)
136 {
137 }
138 public function debug($a_message, $a_context = array())
139 {
140 }
141 public function info($a_message)
142 {
143 }
144 public function notice($a_message)
145 {
146 }
147 public function warning($a_message)
148 {
149 }
150 public function error($a_message)
151 {
152 }
153 public function critical($a_message)
154 {
155 }
156 public function alert($a_message)
157 {
158 }
159 public function emergency($a_message)
160 {
161 }
162 public function write($a_message, $a_level = ilLogLevel::INFO)
163 {
164 }
165 public function writeLanguageLog($a_topic, $a_lang_key)
166 {
167 }
168 public function logStack($a_level = null, $a_message = '')
169 {
170 }
171 public function writeMemoryPeakUsage($a_level)
172 {
173 }
174 };
175 $GLOBALS["DIC"]["ilLog"] = new class() extends ilLog {
176 public function __construct()
177 {
178 }
179 public function write($m, $l = ilLogLevel::INFO)
180 {
181 }
182 public function info($msg)
183 {
184 }
185 public function warning($msg)
186 {
187 }
188 public function error($msg)
189 {
190 }
191 public function debug($msg, $a = [])
192 {
193 }
194 public function dump($msg, $a = ilLogLevel::INFO)
195 {
196 }
197 };
198 $GLOBALS["DIC"]["ilLoggerFactory"] = new class() extends ilLoggerFactory {
199 public function __construct()
200 {
201 }
202 public static function getRootLogger()
203 {
204 return $GLOBALS["DIC"]["ilLogger"];
205 }
206 public static function getLogger($a)
207 {
208 return $GLOBALS["DIC"]["ilLogger"];
209 }
210 };
211 $GLOBALS["ilLog"] = $GLOBALS["DIC"]["ilLog"];
212 $GLOBALS["DIC"]["ilBench"] = null;
213 $GLOBALS["DIC"]["lng"] = new ilLanguage('en');
214 $GLOBALS["DIC"]["ilPluginAdmin"] = $plugin_admin;
215 $GLOBALS["DIC"]["ilCtrl"] = new ilCtrl();
216 $GLOBALS["DIC"]["ilias"] = null;
217 $GLOBALS["DIC"]["ilErr"] = null;
218 $GLOBALS["DIC"]["tree"] = new class() extends ilTree {
219 public function __construct()
220 {
221 }
222 };
223 $GLOBALS["DIC"]["ilAppEventHandler"] = new class() extends ilAppEventHandler {
224 public function __construct()
225 {
226 }
227 public function raise($a_component, $a_event, $a_parameter = "") : void
228 {
229 }
230 };
231 $GLOBALS["DIC"]["ilObjDataCache"] = new ilObjectDataCache();
232 $GLOBALS["DIC"]["ilSetting"] = new ilSetting();
233 $GLOBALS["DIC"]["objDefinition"] = new ilObjectDefinition();
234 $GLOBALS["DIC"]["rbacadmin"] = new class() extends ilRbacAdmin {
235 public function __construct()
236 {
237 }
238 };
239 $GLOBALS["DIC"]["rbacreview"] = new class() extends ilRbacReview {
240 public function __construct()
241 {
242 }
243 };
244 $GLOBALS["DIC"]["ilUser"] = new class() extends ilObjUser {
245 public $prefs = [];
246
247 public function __construct()
248 {
249 $this->prefs["language"] = "en";
250 }
251 };
252
253 if (!defined('DEBUG')) {
254 define('DEBUG', false);
255 }
256
257 if (!defined("ILIAS_ABSOLUTE_PATH")) {
258 define("ILIAS_ABSOLUTE_PATH", dirname(__FILE__, 5));
259 }
260
261 if (!defined('SYSTEM_ROLE_ID')) {
262 define('SYSTEM_ROLE_ID', '2');
263 }
264
265 if (!defined("CLIENT_ID")) {
266 define('CLIENT_ID', $client_ini->readVariable('client', 'name'));
267 }
268
269 if (!defined("ILIAS_WEB_DIR")) {
270 define('ILIAS_WEB_DIR', dirname(__DIR__, 4) . "/data/");
271 }
272
273 return [$ORIG_DIC, $ORIG_ilDB];
274 }
275}
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
Read the client id of the installation from the data directory.
error($a_errmsg)
set error message @access public
Global event handler.
isApplicable(Setup\Environment $environment)
@inheritDoc
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