ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilDatabaseSetupAgent.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22use ILIAS\Setup\Agent\HasNoNamedObjective;
30use ILIAS\Refinery\Factory as Refinery;
32
34{
35 use HasNoNamedObjective;
36
37 public function __construct(protected Refinery $refinery)
38 {
39 }
40
44 public function hasConfig(): bool
45 {
46 return true;
47 }
48
53 {
54 // TODO: Migrate this to refinery-methods once possible.
55 return $this->refinery->custom()->transformation(function ($data): \ilDatabaseSetupConfig {
56 $data["password"] ??= null; // password can be empty
57 $password = $this->refinery->to()->data("password");
58 return new \ilDatabaseSetupConfig(
59 $data["type"] ?? "innodb",
60 $data["host"] ?? "localhost",
61 $data["database"] ?? "ilias",
62 $data["user"] ?? null,
63 $data["password"] ? $password->transform($data["password"]) : null,
64 $data["create_database"] ?? true,
65 $data["collation"] ?? null,
66 (int) ($data["port"] ?? 3306),
67 $data["path_to_db_dump"] ?? null
68 );
69 });
70 }
71
75 public function getInstallObjective(?Config $config = null): Objective
76 {
77 if (!$config instanceof \ilDatabaseSetupConfig) {
78 return new NullObjective();
79 }
80 return new ObjectiveCollection(
81 "Complete objectives from Services\Database",
82 false,
86 );
87 }
88
92 public function getUpdateObjective(?Config $config = null): Objective
93 {
94 $p = [];
95 $p[] = new \ilDatabaseUpdatedObjective();
97 return new ObjectiveCollection(
98 "Complete objectives from Services\Database",
99 false,
100 ...$p
101 );
102 }
103
107 public function getBuildObjective(): Objective
108 {
109 return new NullObjective();
110 }
111
115 public function getStatusObjective(Storage $storage): Objective
116 {
117 return new ilDatabaseMetricsCollectedObjective($storage);
118 }
119
123 public function getMigrations(): array
124 {
125 return [
127 ];
128 }
129
130 public function getNamedObjectives(?Config $config = null): array
131 {
132 return [
133 'resetFailedSteps' => new ObjectiveConstructor(
134 'reset null-states in il_db_steps',
135 static fn(): Objective => new ilDatabaseResetStepsObjective()
136 )
137 ];
138 }
139}
Builds data types.
Definition: Factory.php:36
A objective collection is a objective that is achieved once all subobjectives are achieved.
A non-objective, nothing to do to achieve it...
getArrayToConfigTransformation()
@inheritdocs
__construct(protected Refinery $refinery)
getNamedObjectives(?Config $config=null)
Gets all named objectives The keys of the returned array are the commands.
getInstallObjective(?Config $config=null)
@inheritdocs
getUpdateObjective(?Config $config=null)
@inheritdocs
A transformation is a function from one datatype to another.
A agent is some component that performs part of the setup process.
Definition: Agent.php:30
A configuration for the setup.
Definition: Config.php:27
An objective is a desired state of the system that is supposed to be created by the setup.
Definition: Objective.php:31