ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilIniFilesLoadedObjective.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
6
8{
9 // ATTENTION: This is an evil hack to make bootstrapping of the system simpler.
10 // We have three variariations on loading ini-files: (1) during the setup,
11 // (2) after the setup and while collecting status (3). It should be simple
12 // for consumers in ILIAS (and plugins) to attempt to load ini files in all
13 // circumstances. Hence one objective. Still, the details on how this should
14 // be achieved vary. For (1), we want to populate and load the files. For (2)
15 // we want to just load the files, but make sure they are populated. For (3)
16 // we want to maybe load the files if they exist, but not populate them for
17 // sure. This is the switch to change that behaviour, but also maintain the
18 // simple interface. There for sure are other ways to achieve this, maybe
19 // even better ones, but this hack seems to be okish atm. I suspect it
20 // could go away when we work on the system on how inis are build, the clients
21 // (abandoned) are implemented and the config is loaded in general, but this
22 // is task for another day. If anyone has an idea or wants to work on getting
23 // rid of these, feel free to get in contact with Richard.
25
26 public function getHash() : string
27 {
28 return hash("sha256", self::class);
29 }
30
31 public function getLabel() : string
32 {
33 return "The ilias.ini.php and client.ini.php are loaded";
34 }
35
36 public function isNotable() : bool
37 {
38 return false;
39 }
40
41 public function getPreconditions(Setup\Environment $environment) : array
42 {
43 if (self::$might_populate_ini_files_as_well) {
44 return [
47 ];
48 } else {
49 return [
51 ];
52 }
53 }
54
55 public function achieve(Setup\Environment $environment) : Setup\Environment
56 {
57 $client_id = $environment->getResource(Setup\Environment::RESOURCE_CLIENT_ID);
58 if ($client_id === null) {
60 "To initialize the ini-files, we need a client id, but it does not " .
61 "exist in the environment."
62 );
63 }
64
65 if ($environment->getResource(Setup\Environment::RESOURCE_ILIAS_INI) == null) {
66 $path = dirname(__DIR__, 2) . "/ilias.ini.php";
67 $ini = new ilIniFile($path);
68 $ini->read();
69 $environment = $environment
70 ->withResource(Setup\Environment::RESOURCE_ILIAS_INI, $ini);
71 }
72
73 if ($environment->getResource(Setup\Environment::RESOURCE_CLIENT_INI) == null) {
74 $path = $this->getClientDir($client_id) . "/client.ini.php";
75 $client_ini = new ilIniFile($path);
76 $client_ini->read();
77 $environment = $environment
78 ->withResource(Setup\Environment::RESOURCE_CLIENT_INI, $client_ini);
79 }
80
81 return $environment;
82 }
83
87 public function isApplicable(Setup\Environment $environment) : bool
88 {
89 $ini = $environment->getResource(Setup\Environment::RESOURCE_ILIAS_INI);
90 $client_ini = $environment->getResource(Setup\Environment::RESOURCE_CLIENT_INI);
91
92 return is_null($ini) || is_null($client_ini);
93 }
94
95 protected function getClientDir($client_id) : string
96 {
97 return dirname(__DIR__, 2) . "/data/$client_id";
98 }
99}
An exception for terminatinating execution or to throw for unit testing.
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.
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:12
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...
$ini
Definition: raiseError.php:4
$client_id
Definition: webdav.php:17