ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilDatabaseInitializedObjective Class Reference
+ Inheritance diagram for ilDatabaseInitializedObjective:
+ Collaboration diagram for ilDatabaseInitializedObjective:

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...
 
 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 25 of file class.ilDatabaseInitializedObjective.php.

Member Function Documentation

◆ achieve()

ilDatabaseInitializedObjective::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 62 of file class.ilDatabaseInitializedObjective.php.

63 {
64 if ($environment->getResource(Environment::RESOURCE_DATABASE)) {
65 return $environment;
66 }
67
68 $client_ini = $environment->getResource(Environment::RESOURCE_CLIENT_INI);
69
70 $type = $client_ini->readVariable("db", "type");
71 if ($type === "") {
73 }
74
76 $db->initFromIniFile($client_ini);
77 $connect = $db->connect(true);
78 if (!$connect) {
79 throw new UnachievableException(
80 "Database cannot be connected."
81 );
82 }
83
84 return $environment->withResource(Environment::RESOURCE_DATABASE, $db);
85 }
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
getResource(string $id)
Consumers of this method should check if the result is what they expect, e.g.
withResource(string $id, $resource)

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

+ Here is the call graph for this function:

◆ getHash()

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

27 : string
28 {
29 return hash("sha256", self::class);
30 }

◆ getLabel()

ilDatabaseInitializedObjective::getLabel ( )

Get a label that describes this objective.

Implements ILIAS\Setup\Objective.

Definition at line 32 of file class.ilDatabaseInitializedObjective.php.

32 : string
33 {
34 return "The database object is initialized.";
35 }

◆ getPreconditions()

ilDatabaseInitializedObjective::getPreconditions ( Environment  $environment)
Returns
array<\ilIniFilesLoadedObjective>|array<\ilDatabaseConfigStoredObjective|\ilDatabasePopulatedObjective>

Implements ILIAS\Setup\Objective.

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

45 : array
46 {
47 // If there is no config for the database the existing config seems
48 // to be ok, and we can just connect.
49 if (!$environment->hasConfigFor("database")) {
50 return [
52 ];
53 }
54
55 $config = $environment->getConfigFor("database");
56 return [
59 ];
60 }
hasConfigFor(string $component)
getConfigFor(string $component)

References ILIAS\Setup\Environment\getConfigFor(), and ILIAS\Setup\Environment\hasConfigFor().

+ Here is the call graph for this function:

◆ isApplicable()

ilDatabaseInitializedObjective::isApplicable ( Environment  $environment)

@inheritDoc

Implements ILIAS\Setup\Objective.

Definition at line 90 of file class.ilDatabaseInitializedObjective.php.

90 : bool
91 {
92 return $environment->getResource(Environment::RESOURCE_CLIENT_INI) !== null;
93 }

References ILIAS\Setup\Environment\getResource().

+ Here is the call graph for this function:

◆ isNotable()

ilDatabaseInitializedObjective::isNotable ( )

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

Implements ILIAS\Setup\Objective.

Definition at line 37 of file class.ilDatabaseInitializedObjective.php.

37 : bool
38 {
39 return true;
40 }

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