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

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)
 Get to know whether the objective is applicable. More...
 
- Public Member Functions inherited from ilDatabaseObjective
 __construct (protected \ilDatabaseSetupConfig $config)
 
 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 25 of file class.ilDatabaseConfigStoredObjective.php.

Member Function Documentation

◆ achieve()

ilDatabaseConfigStoredObjective::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.

Implements ILIAS\Setup\Objective.

Definition at line 53 of file class.ilDatabaseConfigStoredObjective.php.

54 {
55 $client_ini = $environment->getResource(Environment::RESOURCE_CLIENT_INI);
56
57 $type = $this->config->getType();
58
59 if ($type === 'postgres' || $type === 'pdo-postgre') {
60 throw new NotExecutableException('ILIAS 8 no longer Supports POSTGRES');
61 }
62
63 $client_ini->setVariable("db", "type", $type);
64 $client_ini->setVariable("db", "host", $this->config->getHost());
65 $client_ini->setVariable("db", "name", $this->config->getDatabase());
66 $client_ini->setVariable("db", "user", $this->config->getUser());
67 $client_ini->setVariable("db", "port", (string) ($this->config->getPort() ?? ""));
68 $pw = $this->config->getPassword();
69 $client_ini->setVariable("db", "pass", $pw !== null ? $pw->toString() : "");
70
71 if (!$client_ini->write()) {
72 throw new UnachievableException("Could not write client.ini.php");
73 }
74
75 return $environment;
76 }
Signals that the setup is not executable at all.
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:28
getResource(string $id)
Consumers of this method should check if the result is what they expect, e.g.

References ILIAS\Setup\Environment\getResource().

+ Here is the call graph for this function:

◆ getHash()

ilDatabaseConfigStoredObjective::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 27 of file class.ilDatabaseConfigStoredObjective.php.

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

◆ getLabel()

ilDatabaseConfigStoredObjective::getLabel ( )

Get a label that describes this objective.

Implements ILIAS\Setup\Objective.

Definition at line 32 of file class.ilDatabaseConfigStoredObjective.php.

32 : string
33 {
34 return "Fill ini with settings for Services/Database";
35 }

◆ getPreconditions()

ilDatabaseConfigStoredObjective::getPreconditions ( Environment  $environment)
Returns
array<int, \ilDatabaseExistsObjective|\ilIniFilesLoadedObjective>

Implements ILIAS\Setup\Objective.

Definition at line 45 of file class.ilDatabaseConfigStoredObjective.php.

◆ isApplicable()

ilDatabaseConfigStoredObjective::isApplicable ( Environment  $environment)

Get to know whether the objective is applicable.

Don't change the environment or cause changes on services in the environment. Just check if this objective needs to be achieved, either currently or at all. In case of doubt whether the objective is applicable or not return true.

Implements ILIAS\Setup\Objective.

Definition at line 78 of file class.ilDatabaseConfigStoredObjective.php.

78 : bool
79 {
80 $client_ini = $environment->getResource(Environment::RESOURCE_CLIENT_INI);
81
82 $port = $this->config->getPort() ?? "";
83 $pass = $this->config->getPassword() !== null ? $this->config->getPassword()->toString() : "";
84 if ($client_ini->readVariable("db", "type") !== $this->config->getType()) {
85 return true;
86 }
87 if ($client_ini->readVariable("db", "host") !== $this->config->getHost()) {
88 return true;
89 }
90 if ($client_ini->readVariable("db", "name") !== $this->config->getDatabase()) {
91 return true;
92 }
93 if ($client_ini->readVariable("db", "user") !== $this->config->getUser()) {
94 return true;
95 }
96 if ($client_ini->readVariable("db", "port") !== $port) {
97 return true;
98 }
99 return $client_ini->readVariable("dv", "pass") !== $pass;
100 }

References ILIAS\Setup\Environment\getResource().

+ Here is the call graph for this function:

◆ isNotable()

ilDatabaseConfigStoredObjective::isNotable ( )

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

Implements ILIAS\Setup\Objective.

Definition at line 37 of file class.ilDatabaseConfigStoredObjective.php.

37 : bool
38 {
39 return false;
40 }

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