ILIAS  trunk Revision v11.0_alpha-1715-g7fc467680fb
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
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)
 

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

Implements ILIAS\Setup\Objective.

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

References ILIAS\Setup\Environment\getResource(), and null.

53  : Environment
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.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
Signals that some goal won't be achievable by actions of the system ever.
getResource(string $id)
Consumers of this method should check if the result is what they expect, e.g.
An environment holds resources to be used in the setup process.
Definition: Environment.php:27
+ 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, |>

Implements ILIAS\Setup\Objective.

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

45  : array
46  {
47  return [
49  new ilDatabaseExistsObjective($this->config)
50  ];
51  }

◆ 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.

References ILIAS\Setup\Environment\getResource(), and null.

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  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
getResource(string $id)
Consumers of this method should check if the result is what they expect, e.g.
+ 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: