ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilDatabaseUpdatedObjective.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 2019 Richard Klees <richard.klees@concepts-and-training.de> Extended GPL, see docs/LICENSE */
4
6use ILIAS\DI;
7
9{
10 public function getHash() : string
11 {
12 return hash("sha256", self::class);
13 }
14
15 public function getLabel() : string
16 {
17 return "The database is updated.";
18 }
19
20 public function isNotable() : bool
21 {
22 return true;
23 }
24
25 public function getPreconditions(Setup\Environment $environment) : array
26 {
27 return [
30 new \ilDatabaseInitializedObjective()
31 ];
32 }
33
34 public function achieve(Setup\Environment $environment) : Setup\Environment
35 {
36 $db = $environment->getResource(Setup\Environment::RESOURCE_DATABASE);
37 $io = $environment->getResource(Setup\Environment::RESOURCE_ADMIN_INTERACTION);
38 $ini = $environment->getResource(Setup\Environment::RESOURCE_ILIAS_INI);
39 $client_ini = $environment->getResource(Setup\Environment::RESOURCE_CLIENT_INI);
40 $client_id = $environment->getResource(Setup\Environment::RESOURCE_CLIENT_ID);
41
42 // ATTENTION: This is a total abomination. It only exists to allow the db-
43 // update to run. This is a memento to the fact, that dependency injection
44 // is something we want. Currently, every component could just service
45 // locate the whole world via the global $DIC.
46 $DIC = $GLOBALS["DIC"] ?? [];
47 $GLOBALS["DIC"] = new DI\Container();
48 $GLOBALS["DIC"]["ilDB"] = $db;
49 $GLOBALS["ilDB"] = $db;
50 $GLOBALS["DIC"]["ilBench"] = null;
51 $GLOBALS["DIC"]["ilLog"] = new class($io) {
52 public function __construct($io)
53 {
54 $this->io = $io;
55 }
56 public function write()
57 {
58 }
59 public function info()
60 {
61 }
62 public function warning($msg)
63 {
64 $this->io->inform($msg);
65 }
66 public function error($msg)
67 {
69 "Problem in DB-Update: $msg"
70 );
71 }
72 };
73 $GLOBALS["ilLog"] = $GLOBALS["DIC"]["ilLog"];
74 $GLOBALS["DIC"]["ilLoggerFactory"] = new class() {
75 public function getRootLogger()
76 {
77 return new class() {
78 public function write()
79 {
80 }
81 };
82 }
83 };
84 $GLOBALS["ilCtrlStructureReader"] = new class() {
85 public function getStructure()
86 {
87 }
88 public function setIniFile()
89 {
90 }
91 };
92 if (!defined("CLIENT_DATA_DIR")) {
93 define("CLIENT_DATA_DIR", $ini->readVariable("clients", "datadir") . "/" . $client_id);
94 }
95 if (!defined("CLIENT_WEB_DIR")) {
96 define("CLIENT_WEB_DIR", dirname(__DIR__, 4) . "/data/" . $client_id);
97 }
98 if (!defined("ILIAS_ABSOLUTE_PATH")) {
99 define("ILIAS_ABSOLUTE_PATH", dirname(__FILE__, 5));
100 }
101 if (!defined("ILIAS_LOG_ENABLED")) {
102 define("ILIAS_LOG_ENABLED", false);
103 }
104 if (!defined("ROOT_FOLDER_ID")) {
105 define("ROOT_FOLDER_ID", $client_ini->readVariable("system", "ROOT_FOLDER_ID"));
106 }
107 if (!defined("ROLE_FOLDER_ID")) {
108 define("ROLE_FOLDER_ID", $client_ini->readVariable("system", "ROLE_FOLDER_ID"));
109 }
110 if (!defined("SYSTEM_FOLDER_ID")) {
111 define("SYSTEM_FOLDER_ID", $client_ini->readVariable("system", "SYSTEM_FOLDER_ID"));
112 }
113
114 $db_update = new class($db, $client_ini) extends ilDBUpdate {
115 public function loadXMLInfo()
116 {
117 }
118 };
119
120 $db_update->applyUpdate();
121 $db_update->applyHotfix();
122 $db_update->applyCustomUpdates();
123
124 return $environment;
125 }
126
130 public function isApplicable(Setup\Environment $environment) : bool
131 {
132 return true;
133 }
134}
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.
Signals that some goal won't be achievable by actions of the system ever.
error($a_errmsg)
set error message @access public
Database Update class.
applyUpdate($a_break=0)
Apply update.
achieve(Setup\Environment $environment)
getPreconditions(Setup\Environment $environment)
isApplicable(Setup\Environment $environment)
@inheritDoc
global $DIC
Definition: goto.php:24
An environment holds resources to be used in the setup process.
Definition: Environment.php:12
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:15
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$ini
Definition: raiseError.php:4
info()
Definition: info.php:2
$client_id
Definition: webdav.php:17