ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilPluginLanguageUpdatedObjective.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21use ILIAS\Setup;
22use ILIAS\DI;
24
26{
27 protected string $plugin_name;
28
29 public function __construct(string $plugin_name)
30 {
31 $this->plugin_name = $plugin_name;
32 }
33
37 public function getHash(): string
38 {
39 return hash("sha256", self::class . $this->plugin_name);
40 }
41
45 public function getLabel(): string
46 {
47 return "Update plugin language $this->plugin_name.";
48 }
49
53 public function isNotable(): bool
54 {
55 return true;
56 }
57
61 public function getPreconditions(Setup\Environment $environment): array
62 {
63 return [
64 new \ilIniFilesLoadedObjective(),
65 new \ilDatabaseInitializedObjective(),
68 ];
69 }
70
74 public function achieve(Setup\Environment $environment): Setup\Environment
75 {
76 $component_repository = $environment->getResource(Setup\Environment::RESOURCE_COMPONENT_REPOSITORY);
77 [$ORIG_DIC, $ORIG_ilDB] = $this->initEnvironment($environment, $component_repository);
78
79 $plugin = $component_repository->getPluginByName($this->plugin_name);
80 $language_handler = new ilPluginLanguage($plugin);
81 $language_handler->updateLanguages();
82
83 $GLOBALS["DIC"] = $ORIG_DIC;
84 $GLOBALS["ilDB"] = $ORIG_ilDB;
85
86 return $environment;
87 }
88
92 public function isApplicable(Setup\Environment $environment): bool
93 {
94 $component_repository = $environment->getResource(Setup\Environment::RESOURCE_COMPONENT_REPOSITORY);
95
96 return $component_repository->getPluginByName($this->plugin_name)->supportsCLISetup();
97 }
98
99 protected function initEnvironment(Setup\Environment $environment, \ilComponentRepository $component_repository): array
100 {
101 $db = $environment->getResource(Setup\Environment::RESOURCE_DATABASE);
102 $ini = $environment->getResource(Setup\Environment::RESOURCE_ILIAS_INI);
103 $client_ini = $environment->getResource(Setup\Environment::RESOURCE_CLIENT_INI);
104 $component_factory = $environment->getResource(Setup\Environment::RESOURCE_COMPONENT_FACTORY);
105
106
107 // ATTENTION: This is a total abomination. It only exists to allow various
108 // sub components of the various readers to run. This is a memento to the
109 // fact, that dependency injection is something we want. Currently, every
110 // component could just service locate the whole world via the global $DIC.
111 $ORIG_DIC = $GLOBALS["DIC"];
112 $ORIG_ilDB = $GLOBALS["ilDB"];
113
114 $GLOBALS["DIC"] = new DI\Container();
115 $GLOBALS["DIC"]["ilDB"] = $db;
116 $GLOBALS["ilDB"] = $db;
117 $GLOBALS["DIC"]["ilIliasIniFile"] = $ini;
118 $GLOBALS["DIC"]["ilClientIniFile"] = $client_ini;
119 $GLOBALS["DIC"]["ilLog"] = new NullLogger();
120 $GLOBALS["DIC"]["ilLoggerFactory"] = new class () extends ilLoggerFactory {
121 public function __construct()
122 {
123 }
124 public static function getRootLogger(): ilLogger
125 {
126 return $GLOBALS["DIC"]["ilLog"];
127 }
128 public static function getLogger(string $a_component_id): ilLogger
129 {
130 return $GLOBALS["DIC"]["ilLog"];
131 }
132 };
133 $GLOBALS["ilLog"] = $GLOBALS["DIC"]["ilLog"];
134 $GLOBALS["DIC"]["ilBench"] = null;
135 $GLOBALS["DIC"]["lng"] = new ilLanguage('en');
136 $GLOBALS["DIC"]["lng"]->lang_user = "en";
137 $GLOBALS["DIC"]["ilias"] = null;
138 $GLOBALS["DIC"]["ilErr"] = null;
139 $GLOBALS["DIC"]["tree"] = new class () extends ilTree {
140 public function __construct()
141 {
142 }
143 };
144 $GLOBALS["DIC"]["ilAppEventHandler"] = new class () extends ilAppEventHandler {
145 public function __construct()
146 {
147 }
148 public function raise($a_component, $a_event, $a_parameter = ""): void
149 {
150 }
151 };
152 $GLOBALS["DIC"]["ilObjDataCache"] = new ilObjectDataCache();
153 $GLOBALS["DIC"]["ilSetting"] = new ilSetting();
154 $GLOBALS["DIC"]["component.repository"] = $component_repository;
155 $GLOBALS["DIC"]["component.factory"] = $component_factory;
156 $GLOBALS["DIC"]["objDefinition"] = new ilObjectDefinition();
157 $GLOBALS["DIC"]["rbacadmin"] = new class () extends ilRbacAdmin {
158 public function __construct()
159 {
160 }
161 };
162 $GLOBALS["DIC"]["rbacreview"] = new class () extends ilRbacReview {
163 public function __construct()
164 {
165 }
166 };
167 $GLOBALS["DIC"]["ilUser"] = new class () extends ilObjUser {
168 public function __construct()
169 {
170 $this->prefs["language"] = "en";
171 }
172 };
173
174 if (!defined('DEBUG')) {
175 define('DEBUG', false);
176 }
177
178 if (!defined("ILIAS_ABSOLUTE_PATH")) {
179 define("ILIAS_ABSOLUTE_PATH", dirname(__FILE__, 6));
180 }
181
182 if (!defined('SYSTEM_ROLE_ID')) {
183 define('SYSTEM_ROLE_ID', '2');
184 }
185
186 if (!defined("CLIENT_ID")) {
187 define('CLIENT_ID', $client_ini->readVariable('client', 'name'));
188 }
189
190 if (!defined("ILIAS_WEB_DIR")) {
191 define('ILIAS_WEB_DIR', $ini->readVariable('clients', 'path'));
192 }
193
194 return [$ORIG_DIC, $ORIG_ilDB];
195 }
196}
Customizing of pimple-DIC for ILIAS.
Definition: Container.php:36
Global event handler.
language handling
Component logger with individual log levels by component id.
User class.
class ilObjectDataCache
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
Class ilRbacAdmin Core functions for role based access control.
class ilRbacReview Contains Review functions of core Rbac.
ILIAS Setting Class.
language handling for setup
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: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:20
$GLOBALS["DIC"]
Definition: wac.php:54