ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilIniFilesLoadedObjective.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21use ILIAS\Setup;
22
24{
25 // ATTENTION: This is an evil hack to make bootstrapping of the system simpler.
26 // We have three variariations on loading ini-files: (1) during the setup,
27 // (2) after the setup and while collecting status (3). It should be simple
28 // for consumers in ILIAS (and plugins) to attempt to load ini files in all
29 // circumstances. Hence one objective. Still, the details on how this should
30 // be achieved vary. For (1), we want to populate and load the files. For (2)
31 // we want to just load the files, but make sure they are populated. For (3)
32 // we want to maybe load the files if they exist, but not populate them for
33 // sure. This is the switch to change that behaviour, but also maintain the
34 // simple interface. There for sure are other ways to achieve this, maybe
35 // even better ones, but this hack seems to be okish atm. I suspect it
36 // could go away when we work on the system on how inis are build, the clients
37 // (abandoned) are implemented and the config is loaded in general, but this
38 // is task for another day. If anyone has an idea or wants to work on getting
39 // rid of these, feel free to get in contact with Richard.
40 public static bool $might_populate_ini_files_as_well = true;
41
42 public function getHash(): string
43 {
44 return hash("sha256", self::class);
45 }
46
47 public function getLabel(): string
48 {
49 return "The ilias.ini.php and client.ini.php are loaded";
50 }
51
52 public function isNotable(): bool
53 {
54 return false;
55 }
56
57 public function getPreconditions(Setup\Environment $environment): array
58 {
59 if (self::$might_populate_ini_files_as_well) {
60 return [
63 ];
64 } else {
65 return [
67 ];
68 }
69 }
70
71 public function achieve(Setup\Environment $environment): Setup\Environment
72 {
73 $client_id = $environment->getResource(Setup\Environment::RESOURCE_CLIENT_ID);
74 if ($client_id === null) {
76 "To initialize the ini-files, we need a client id, but it does not " .
77 "exist in the environment."
78 );
79 }
80
81 if ($environment->getResource(Setup\Environment::RESOURCE_ILIAS_INI) == null) {
82 $path = dirname(__DIR__, 4) . "/ilias.ini.php";
83 $ini = new ilIniFile($path);
84 $ini->read();
85 $environment = $environment
86 ->withResource(Setup\Environment::RESOURCE_ILIAS_INI, $ini);
87 }
88
89 if ($environment->getResource(Setup\Environment::RESOURCE_CLIENT_INI) == null) {
90 $path = $this->getClientDir($client_id) . "/client.ini.php";
91 $client_ini = new ilIniFile($path);
92 $client_ini->read();
93 $environment = $environment
94 ->withResource(Setup\Environment::RESOURCE_CLIENT_INI, $client_ini);
95 }
96
97 return $environment;
98 }
99
103 public function isApplicable(Setup\Environment $environment): bool
104 {
105 $ini = $environment->getResource(Setup\Environment::RESOURCE_ILIAS_INI);
106 $client_ini = $environment->getResource(Setup\Environment::RESOURCE_CLIENT_INI);
107
108 return is_null($ini) || is_null($client_ini);
109 }
110
111 protected function getClientDir($client_id): string
112 {
113 return dirname(__DIR__, 4) . "/public/data/$client_id";
114 }
115}
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.
INIFile Parser Early access in init proceess! Avoid further dependencies like logging or other servic...
isApplicable(Setup\Environment $environment)
@inheritDoc
achieve(Setup\Environment $environment)
getPreconditions(Setup\Environment $environment)
An environment holds resources to be used in the setup process.
Definition: Environment.php:28
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
$path
Definition: ltiservices.php:30
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$ini
Definition: raiseError.php:20