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

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)
 
- Public Member Functions inherited from ilDatabaseObjective
 __construct (protected \ilDatabaseSetupConfig $config)
 

Detailed Description

Definition at line 24 of file class.ilDatabaseExistsObjective.php.

Member Function Documentation

◆ achieve()

ilDatabaseExistsObjective::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 60 of file class.ilDatabaseExistsObjective.php.

References ilDBWrapperFactory\getWrapper(), and ILIAS\Setup\Environment\withResource().

60  : Environment
61  {
62  $db = \ilDBWrapperFactory::getWrapper($this->config->getType());
63  $db->initFromIniFile($this->config->toMockIniFile());
64  $connect = $db->connect(true);
65  if (!$connect) {
66  throw new UnachievableException(
67  "Database cannot be connected. Please check the credentials."
68  );
69  }
70 
71  return $environment->withResource(Environment::RESOURCE_DATABASE, $db);
72  }
withResource(string $id, $resource)
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()

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

26  : string
27  {
28  return hash("sha256", implode("-", [
29  self::class,
30  $this->config->getHost(),
31  $this->config->getPort(),
32  $this->config->getDatabase()
33  ]));
34  }

◆ getLabel()

ilDatabaseExistsObjective::getLabel ( )

Get a label that describes this objective.

Implements ILIAS\Setup\Objective.

Definition at line 36 of file class.ilDatabaseExistsObjective.php.

36  : string
37  {
38  return "The database exists on the server.";
39  }

◆ getPreconditions()

ilDatabaseExistsObjective::getPreconditions ( Environment  $environment)
Returns
array<|>

Implements ILIAS\Setup\Objective.

Definition at line 49 of file class.ilDatabaseExistsObjective.php.

49  : array
50  {
51  $preconditions = [
52  new \ilDatabaseServerIsConnectableObjective($this->config)
53  ];
54  if ($this->config->getCreateDatabase()) {
55  $preconditions[] = new \ilDatabaseCreatedObjective($this->config);
56  }
57  return $preconditions;
58  }

◆ isApplicable()

ilDatabaseExistsObjective::isApplicable ( Environment  $environment)

Implements ILIAS\Setup\Objective.

Definition at line 77 of file class.ilDatabaseExistsObjective.php.

77  : bool
78  {
79  return true;
80  }

◆ isNotable()

ilDatabaseExistsObjective::isNotable ( )

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

Implements ILIAS\Setup\Objective.

Definition at line 41 of file class.ilDatabaseExistsObjective.php.

41  : bool
42  {
43  return true;
44  }

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