ILIAS  trunk Revision v12.0_alpha-1227-g7ff6d300864
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;
33
35{
36 use HasNoNamedObjective;
37
38 public function __construct(protected Refinery $refinery)
39 {
40 }
41
45 public function hasConfig(): bool
46 {
47 return true;
48 }
49
54 {
55 // TODO: Migrate this to refinery-methods once possible.
56 return $this->refinery->custom()->transformation(function ($data): \ilDatabaseSetupConfig {
57 $data["password"] ??= null; // password can be empty
58 $password = $this->refinery->to()->data("password");
59 return new \ilDatabaseSetupConfig(
60 $data["type"] ?? "innodb",
61 $data["host"] ?? "localhost",
62 $data["database"] ?? "ilias",
63 $data["user"] ?? null,
64 $data["password"] ? $password->transform($data["password"]) : null,
65 $data["create_database"] ?? true,
66 $data["collation"] ?? null,
67 (int) ($data["port"] ?? 3306),
68 $data["path_to_db_dump"] ?? null
69 );
70 });
71 }
72
76 public function getInstallObjective(?Config $config = null): Objective
77 {
78 if (!$config instanceof \ilDatabaseSetupConfig) {
79 return new NullObjective();
80 }
81 return new ObjectiveCollection(
82 "Complete objectives from Services\Database",
83 false,
88 );
89 }
90
94 public function getUpdateObjective(?Config $config = null): Objective
95 {
96 $p = [];
97 $p[] = new CalledFromRootObjective();
98 $p[] = new \ilDatabaseUpdatedObjective();
100 return new ObjectiveCollection(
101 "Complete objectives from Services\Database",
102 false,
103 ...$p
104 );
105 }
106
110 public function getBuildObjective(): Objective
111 {
112 return new NullObjective();
113 }
114
118 public function getStatusObjective(Storage $storage): Objective
119 {
120 return new ilDatabaseMetricsCollectedObjective($storage);
121 }
122
126 public function getMigrations(): array
127 {
128 return [
130 ];
131 }
132
133 public function getNamedObjectives(?Config $config = null): array
134 {
135 return [
136 'resetFailedSteps' => new ObjectiveConstructor(
137 'reset null-states in il_db_steps',
138 static fn(): Objective => new ilDatabaseResetStepsObjective()
139 )
140 ];
141 }
142}
Builds data types.
Definition: Factory.php:36
A objective collection is a objective that is achieved once all subobjectives are achieved.
Verify that the setip is called from ILIAS root directory.
A non-objective, nothing to do to achieve it...
getArrayToConfigTransformation()
@inheritdocs
__construct(protected Refinery $refinery)
getStatusObjective(Storage $storage)
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