ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilDatabaseUpdatedObjective.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
26
28{
29 public function getHash(): string
30 {
31 return hash("sha256", self::class);
32 }
33
34 public function getLabel(): string
35 {
36 return "The database is updated.";
37 }
38
39 public function isNotable(): bool
40 {
41 return true;
42 }
43
47 public function getPreconditions(Environment $environment): array
48 {
50 }
51
52 public function achieve(Environment $environment): Environment
53 {
54 $db = $environment->getResource(Environment::RESOURCE_DATABASE);
55 $io = $environment->getResource(Environment::RESOURCE_ADMIN_INTERACTION);
56 $ini = $environment->getResource(Environment::RESOURCE_ILIAS_INI);
57 $client_ini = $environment->getResource(Environment::RESOURCE_CLIENT_INI);
58 $client_id = $environment->getResource(Environment::RESOURCE_CLIENT_ID);
59
60 // ATTENTION: This is a total abomination. It only exists to allow the db-
61 // update to run. This is a memento to the fact, that dependency injection
62 // is something we want. Currently, every component could just service
63 // locate the whole world via the global $DIC.
65 $DIC = $GLOBALS["DIC"] ?? [];
66 $GLOBALS["DIC"] = new Container();
67 $GLOBALS["DIC"]["ilDB"] = $db;
68 $GLOBALS["ilDB"] = $db;
69 $GLOBALS["DIC"]["ilBench"] = null;
70 $GLOBALS["DIC"]["ilLog"] = new class ($io) {
71 public function __construct(protected $io)
72 {
73 }
74
75 public function write(): void
76 {
77 }
78
79 public function info(): void
80 {
81 }
82
83 public function warning($msg): void
84 {
85 $this->io->inform($msg);
86 }
87
88 public function error($msg): never
89 {
90 throw new UnachievableException(
91 "Problem in DB-Update: $msg"
92 );
93 }
94 };
95 $GLOBALS["ilLog"] = $GLOBALS["DIC"]["ilLog"];
96 $GLOBALS["DIC"]["ilLoggerFactory"] = new class () {
97 public function getRootLogger(): object
98 {
99 return new class () {
100 public function write(): void
101 {
102 }
103 };
104 }
105 };
106 $GLOBALS["ilCtrlStructureReader"] = new class () {
107 public function getStructure(): void
108 {
109 }
110
111 public function setIniFile(): void
112 {
113 }
114 };
115 if (!defined("CLIENT_DATA_DIR")) {
116 define("CLIENT_DATA_DIR", $ini->readVariable("clients", "datadir") . "/" . $client_id);
117 }
118 if (!defined("CLIENT_WEB_DIR")) {
119 define("CLIENT_WEB_DIR", dirname(__DIR__, 5) . "/public/data/" . $client_id);
120 }
121 if (!defined("ILIAS_ABSOLUTE_PATH")) {
122 define("ILIAS_ABSOLUTE_PATH", dirname(__FILE__, 6));
123 }
124 if (!defined("ILIAS_LOG_ENABLED")) {
125 define("ILIAS_LOG_ENABLED", false);
126 }
127 if (!defined("ROOT_FOLDER_ID")) {
128 define("ROOT_FOLDER_ID", (int) $client_ini->readVariable("system", "ROOT_FOLDER_ID"));
129 }
130 if (!defined("ROLE_FOLDER_ID")) {
131 define("ROLE_FOLDER_ID", (int) $client_ini->readVariable("system", "ROLE_FOLDER_ID"));
132 }
133 if (!defined("SYSTEM_FOLDER_ID")) {
134 define("SYSTEM_FOLDER_ID", (int) $client_ini->readVariable("system", "SYSTEM_FOLDER_ID"));
135 }
136
137 $db_update = new ilDBUpdate($db);
138 $db_update->applyCustomUpdates();
139
140 $GLOBALS["DIC"] = $DIC;
141
142 return $environment;
143 }
144
148 public function isApplicable(Environment $environment): bool
149 {
150 return true;
151 }
152}
Customizing of pimple-DIC for ILIAS.
Definition: Container.php:36
Read the client id of the installation from the data directory.
Signals that some goal won't be achievable by actions of the system ever.
error(string $a_errmsg)
Database Update class.
getHash()
Get a hash for this objective.
getLabel()
Get a label that describes this objective.
isNotable()
Get to know if this is an interesting objective for a human.
achieve(Environment $environment)
Objectives can be achieved.
isApplicable(Environment $environment)
@inheritDoc
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
$client_id
Definition: ltiauth.php:67
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$ini
Definition: raiseError.php:20
global $DIC
Definition: shib_login.php:26
$GLOBALS["DIC"]
Definition: wac.php:54