ILIAS  trunk Revision v11.0_alpha-1749-g1a06bdef097
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilDatabaseServerIsConnectableObjective Class Reference
+ Inheritance diagram for ilDatabaseServerIsConnectableObjective:
+ Collaboration diagram for ilDatabaseServerIsConnectableObjective:

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)
 Objectives might depend on other objectives. More...
 
 achieve (Environment $environment)
 Objectives can be achieved. More...
 
 isApplicable (Environment $environment)
 
- Public Member Functions inherited from ilDatabaseObjective
 __construct (protected \ilDatabaseSetupConfig $config)
 

Detailed Description

Member Function Documentation

◆ achieve()

ilDatabaseServerIsConnectableObjective::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.ilDatabaseServerIsConnectableObjective.php.

References Vendor\Package\$e, and ilDBWrapperFactory\getWrapper().

53  : Environment
54  {
55  $db = \ilDBWrapperFactory::getWrapper($this->config->getType());
56  $db->initFromIniFile($this->config->toMockIniFile());
57  try {
58  $connect = $db->connect();
59  } catch (PDOException $e) {
60  // 1049 is "unknown database", which is ok because we propably didn't
61  // install the db yet,.
62  if ($e->getCode() !== 1049) {
63  throw $e;
64  }
65 
66  $connect = true;
67  }
68  if (!$connect) {
69  throw new UnachievableException(
70  "Database cannot be reached. Please check the credentials."
71  );
72  }
73 
74  return $environment;
75  }
static getWrapper(string $a_type)
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:27
+ Here is the call graph for this function:

◆ getHash()

ilDatabaseServerIsConnectableObjective::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 26 of file class.ilDatabaseServerIsConnectableObjective.php.

References null.

26  : string
27  {
28  $pw = $this->config->getPassword();
29  return hash("sha256", implode("-", [
30  self::class,
31  $this->config->getHost(),
32  $this->config->getPort(),
33  $this->config->getUser(),
34  $pw !== null ? $pw->toString() : ""
35  ]));
36  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null

◆ getLabel()

ilDatabaseServerIsConnectableObjective::getLabel ( )

Get a label that describes this objective.

Implements ILIAS\Setup\Objective.

Definition at line 38 of file class.ilDatabaseServerIsConnectableObjective.php.

38  : string
39  {
40  return "The database server is connectable with the supplied configuration.";
41  }

◆ getPreconditions()

ilDatabaseServerIsConnectableObjective::getPreconditions ( Environment  $environment)

Objectives might depend on other objectives.

Exceptions
UnachievableExceptionif the objective is not achievable
Returns
Objective[]

Implements ILIAS\Setup\Objective.

Definition at line 48 of file class.ilDatabaseServerIsConnectableObjective.php.

48  : array
49  {
50  return [];
51  }

◆ isApplicable()

ilDatabaseServerIsConnectableObjective::isApplicable ( Environment  $environment)

Implements ILIAS\Setup\Objective.

Definition at line 80 of file class.ilDatabaseServerIsConnectableObjective.php.

80  : bool
81  {
82  return true;
83  }

◆ isNotable()

ilDatabaseServerIsConnectableObjective::isNotable ( )

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

Implements ILIAS\Setup\Objective.

Definition at line 43 of file class.ilDatabaseServerIsConnectableObjective.php.

43  : bool
44  {
45  return true;
46  }

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