ILIAS  release_8 Revision v8.19-1-g4e8f2f9140c
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilDatabaseSetupAgent.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
21 use ILIAS\Setup;
24 
25 class ilDatabaseSetupAgent implements Setup\Agent
26 {
28 
29  protected Refinery $refinery;
30 
31  public function __construct(Refinery $refinery)
32  {
33  $this->refinery = $refinery;
34  }
35 
39  public function hasConfig(): bool
40  {
41  return true;
42  }
43 
48  {
49  // TODO: Migrate this to refinery-methods once possible.
50  return $this->refinery->custom()->transformation(function ($data): \ilDatabaseSetupConfig {
51  $data["password"] = $data["password"] ?? null; // password can be empty
52  $password = $this->refinery->to()->data("password");
53  return new \ilDatabaseSetupConfig(
54  $data["type"] ?? "innodb",
55  $data["host"] ?? "localhost",
56  $data["database"] ?? "ilias",
57  $data["user"] ?? null,
58  $data["password"] ? $password->transform($data["password"]) : null,
59  $data["create_database"] ?? true,
60  $data["collation"] ?? null,
61  (int) ($data["port"] ?? 3306),
62  $data["path_to_db_dump"] ?? null
63  );
64  });
65  }
66 
70  public function getInstallObjective(Setup\Config $config = null): Setup\Objective
71  {
72  if (!$config instanceof \ilDatabaseSetupConfig) {
73  return new Setup\Objective\NullObjective();
74  }
75  return new Setup\ObjectiveCollection(
76  "Complete objectives from Services\Database",
77  false,
81  );
82  }
83 
87  public function getUpdateObjective(Setup\Config $config = null): Setup\Objective
88  {
89  $p = [];
90  $p[] = new \ilDatabaseUpdatedObjective();
92  return new Setup\ObjectiveCollection(
93  "Complete objectives from Services\Database",
94  false,
95  ...$p
96  );
97  }
98 
102  public function getBuildArtifactObjective(): Setup\Objective
103  {
104  return new Setup\Objective\NullObjective();
105  }
106 
110  public function getStatusObjective(Setup\Metrics\Storage $storage): Setup\Objective
111  {
112  return new ilDatabaseMetricsCollectedObjective($storage);
113  }
114 
118  public function getMigrations(): array
119  {
120  return [
121  new Setup\ilMysqlMyIsamToInnoDbMigration()
122  ];
123  }
124 
125  public function getNamedObjectives(?Setup\Config $config = null): array
126  {
127  return [
128  'resetFailedSteps' => new Setup\ObjectiveConstructor(
129  'reset null-states in il_db_steps',
130  static fn (): Setup\Objective => new ilDatabaseResetStepsObjective()
131  )
132  ];
133  }
134 }
getStatusObjective(Setup\Metrics\Storage $storage)
An objective is a desired state of the system that is supposed to be created by the setup...
Definition: Objective.php:30
getNamedObjectives(?Setup\Config $config=null)
if(!array_key_exists('PATH_INFO', $_SERVER)) $config
Definition: metadata.php:85
getUpdateObjective(Setup\Config $config=null)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
A transformation is a function from one datatype to another.
getInstallObjective(Setup\Config $config=null)
A configuration for the setup.
Definition: Config.php:26