ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
class.ilDatabaseConfigStoredObjective.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
5
7
9{
10 public function getHash() : string
11 {
12 return hash("sha256", self::class);
13 }
14
15 public function getLabel() : string
16 {
17 return "Fill ini with settings for Services/Database";
18 }
19
20 public function isNotable() : bool
21 {
22 return false;
23 }
24
25 public function getPreconditions(Setup\Environment $environment) : array
26 {
27 $common_config = $environment->getConfigFor("common");
28 return [
29 new ilIniFilesPopulatedObjective($common_config),
30 new ilDatabaseExistsObjective($this->config)
31 ];
32 }
33
34 public function achieve(Setup\Environment $environment) : Setup\Environment
35 {
36 $client_ini = $environment->getResource(Setup\Environment::RESOURCE_CLIENT_INI);
37
38 $client_ini->setVariable("db", "type", $this->config->getType());
39 $client_ini->setVariable("db", "host", $this->config->getHost());
40 $client_ini->setVariable("db", "name", $this->config->getDatabase());
41 $client_ini->setVariable("db", "user", $this->config->getUser());
42 $client_ini->setVariable("db", "port", $this->config->getPort() ?? "");
43 $pw = $this->config->getPassword();
44 $client_ini->setVariable("db", "pass", $pw ? $pw->toString() : "");
45
46 if (!$client_ini->write()) {
47 throw new Setup\UnachievableException("Could not write client.ini.php");
48 }
49
50 return $environment;
51 }
52}
An exception for terminatinating execution or to throw for unit testing.
Signals that some goal won't be achievable by actions of the system ever.
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.