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

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.ilDatabaseCreatedObjective.php.

Member Function Documentation

◆ achieve()

ilDatabaseCreatedObjective::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 56 of file class.ilDatabaseCreatedObjective.php.

57 {
58 $c = $this->config;
59 $db = \ilDBWrapperFactory::getWrapper($this->config->getType());
60 $db->initFromIniFile($c->toMockIniFile());
61
62 if (!$db->createDatabase($c->getDatabase(), "utf8", $c->getCollation())) {
63 throw new UnachievableException(
64 "Database cannot be created."
65 );
66 }
67
68 return $environment;
69 }
Signals that some goal won't be achievable by actions of the system ever.
static getWrapper(string $a_type)
$c
Definition: deliver.php:25
An environment holds resources to be used in the setup process.
Definition: Environment.php:28

References $c, and ilDBWrapperFactory\getWrapper().

+ Here is the call graph for this function:

◆ getHash()

ilDatabaseCreatedObjective::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.ilDatabaseCreatedObjective.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()

ilDatabaseCreatedObjective::getLabel ( )

Get a label that describes this objective.

Implements ILIAS\Setup\Objective.

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

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

◆ getPreconditions()

ilDatabaseCreatedObjective::getPreconditions ( Environment  $environment)
Returns
\ilDatabaseServerIsConnectableObjective[]

Implements ILIAS\Setup\Objective.

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

49 : array
50 {
51 return [
52 new \ilDatabaseServerIsConnectableObjective($this->config)
53 ];
54 }

◆ isApplicable()

ilDatabaseCreatedObjective::isApplicable ( Environment  $environment)

@inheritDoc

Implements ILIAS\Setup\Objective.

Definition at line 74 of file class.ilDatabaseCreatedObjective.php.

74 : bool
75 {
76 $c = $this->config;
77 $db = \ilDBWrapperFactory::getWrapper($this->config->getType());
78 $db->initFromIniFile($c->toMockIniFile());
79
80 $connect = $db->connect(true);
81 return !$connect;
82 }

References $c, and ilDBWrapperFactory\getWrapper().

+ Here is the call graph for this function:

◆ isNotable()

ilDatabaseCreatedObjective::isNotable ( )

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

Implements ILIAS\Setup\Objective.

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

41 : bool
42 {
43 return true;
44 }

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