ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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)
 @inheritDoc 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

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

LogicException if there are unfullfilled preconditions.

Exceptions

RuntimeException if there are missing resources.

Implements ILIAS\Setup\Objective.

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

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 }
Signals that some goal won't be achievable by actions of the system ever.
static getWrapper(string $a_type)
An environment holds resources to be used in the setup process.
Definition: Environment.php:28

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

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

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 }

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

@inheritDoc

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: