ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilDatabaseUpdatedObjective Class Reference
+ Inheritance diagram for ilDatabaseUpdatedObjective:
+ Collaboration diagram for ilDatabaseUpdatedObjective:

Public Member Functions

 getHash ()
 Get a hash for this objective. More...
 
 getLabel ()
 Get a label that describes this objective. More...
 
 isNotable ()
 Get to know if this is an interesting objective for a human. More...
 
 getPreconditions (Environment $environment)
 
 achieve (Environment $environment)
 Objectives can be achieved. More...
 
 isApplicable (Environment $environment)
 @inheritDoc More...
 
 getHash ()
 Get a hash for this objective. More...
 
 getLabel ()
 Get a label that describes this objective. More...
 
 isNotable ()
 Get to know if this is an interesting objective for a human. More...
 
 getPreconditions (Environment $environment)
 Objectives might depend on other objectives. More...
 
 achieve (Environment $environment)
 Objectives can be achieved. More...
 
 isApplicable (Environment $environment)
 Get to know whether the objective is applicable. More...
 

Detailed Description

Definition at line 27 of file class.ilDatabaseUpdatedObjective.php.

Member Function Documentation

◆ achieve()

ilDatabaseUpdatedObjective::achieve ( Environment  $environment)

Objectives can be achieved.

They might add resources to the environment when they have been achieved.

This method needs to be idempotent for a given environment. That means: if this is executed a second time, nothing new should happen. Or the other way round: if the environment already looks like desired, the objective should not take any further actions when this is called.

Exceptions

LogicException if there are unfullfilled preconditions.

Exceptions

RuntimeException if there are missing resources.

@noRector

Implements ILIAS\Setup\Objective.

Definition at line 52 of file class.ilDatabaseUpdatedObjective.php.

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 }
Customizing of pimple-DIC for ILIAS.
Definition: Container.php:36
Signals that some goal won't be achievable by actions of the system ever.
error(string $a_errmsg)
Database Update class.
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.
$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

References $client_id, $DIC, $GLOBALS, $ini, ILIAS\GlobalScreen\Provider\__construct(), error(), ILIAS\Setup\Environment\getResource(), and ILIAS\UI\examples\MessageBox\Info\info().

+ Here is the call graph for this function:

◆ getHash()

ilDatabaseUpdatedObjective::getHash ( )

Get a hash for this objective.

The hash of two objectives must be the same, if they are the same objective, with the same config on the same environment, i.e. if the one is achieved the other is achieved as well because they are the same.

Implements ILIAS\Setup\Objective.

Definition at line 29 of file class.ilDatabaseUpdatedObjective.php.

29 : string
30 {
31 return hash("sha256", self::class);
32 }

◆ getLabel()

ilDatabaseUpdatedObjective::getLabel ( )

Get a label that describes this objective.

Implements ILIAS\Setup\Objective.

Definition at line 34 of file class.ilDatabaseUpdatedObjective.php.

34 : string
35 {
36 return "The database is updated.";
37 }

◆ getPreconditions()

ilDatabaseUpdatedObjective::getPreconditions ( Environment  $environment)
Returns
\ilDatabaseInitializedObjective[]|ClientIdReadObjective[]|\ilIniFilesPopulatedObjective[]

Implements ILIAS\Setup\Objective.

Definition at line 47 of file class.ilDatabaseUpdatedObjective.php.

◆ isApplicable()

ilDatabaseUpdatedObjective::isApplicable ( Environment  $environment)

@inheritDoc

Implements ILIAS\Setup\Objective.

Definition at line 148 of file class.ilDatabaseUpdatedObjective.php.

148 : bool
149 {
150 return true;
151 }

◆ isNotable()

ilDatabaseUpdatedObjective::isNotable ( )

Get to know if this is an interesting objective for a human.

Implements ILIAS\Setup\Objective.

Definition at line 39 of file class.ilDatabaseUpdatedObjective.php.

39 : bool
40 {
41 return true;
42 }

The documentation for this class was generated from the following file: