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

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

LogicException if there are unfullfilled preconditions.

Exceptions

RuntimeException if there are missing resources.

Implements ILIAS\Setup\Objective.

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

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 }
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
withResource(string $id, $resource)

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

+ 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<\ilDatabaseServerIsConnectableObjective|\ilDatabaseCreatedObjective>

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)

@inheritDoc

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: