ILIAS  release_8 Revision v8.23
class.ilSetupAgent.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
21 use ILIAS\Setup;
22 use ILIAS\Refinery;
23 use ILIAS\Data;
26 
32 class ilSetupAgent implements Setup\Agent
33 {
34  private const PHP_MEMORY_LIMIT = "128M";
35  private const PHP_MIN_VERSION = "7.4.0";
36  private const PHP_MAX_VERSION = "8.0.999";
37 
38  protected Refinery\Factory $refinery;
39  protected Data\Factory $data;
40 
41  public function __construct(
42  Refinery\Factory $refinery,
43  Data\Factory $data
44  ) {
45  $this->refinery = $refinery;
46  $this->data = $data;
47  }
48 
52  public function hasConfig(): bool
53  {
54  return true;
55  }
56 
61  {
62  return $this->refinery->custom()->transformation(function ($data) {
63  $datetimezone = $this->refinery->to()->toNew(\DateTimeZone::class);
64  return new \ilSetupConfig(
65  $this->data->clientId($data["client_id"] ?? ''),
66  $datetimezone->transform([$data["server_timezone"] ?? "UTC"]),
67  $data["register_nic"] ?? false
68  );
69  });
70  }
71 
75  public function getInstallObjective(Setup\Config $config = null): Setup\Objective
76  {
77  return new Setup\Objective\ObjectiveWithPreconditions(
80  new Setup\ObjectiveCollection(
81  "Complete common ILIAS objectives.",
82  false,
83  new Setup\Condition\PHPVersionCondition(self::PHP_MIN_VERSION, self::PHP_MAX_VERSION, true),
84  new Setup\Condition\PHPExtensionLoadedCondition("dom"),
85  new Setup\Condition\PHPExtensionLoadedCondition("xsl"),
86  new Setup\Condition\PHPExtensionLoadedCondition("gd"),
89  $config->getRegisterNIC()
91  : new Setup\ObjectiveCollection(
92  "",
93  false,
96  )
97  )
98  );
99  }
100 
101  protected function getPHPMemoryLimitCondition(): Setup\Objective
102  {
103  return new Setup\Condition\ExternalConditionObjective(
104  "PHP memory limit >= " . self::PHP_MEMORY_LIMIT,
105  function (Setup\Environment $env): bool {
106  $limit = ini_get("memory_limit");
107  if ($limit == -1) {
108  return true;
109  }
110  $expected = $this->data->dataSize(self::PHP_MEMORY_LIMIT);
111  $current = $this->data->dataSize($limit);
112  return $current->inBytes() >= $expected->inBytes();
113  },
114  "To properly execute ILIAS, please take care that the PHP memory limit is at least set to 128M."
115  );
116  }
117 
121  public function getUpdateObjective(Setup\Config $config = null): Setup\Objective
122  {
123  $objectives = [
124  new Setup\Objective\ObjectiveWithPreconditions(
125  new ilVersionWrittenToSettingsObjective($this->data),
126  new Setup\Condition\PHPVersionCondition(self::PHP_MIN_VERSION, self::PHP_MAX_VERSION, true),
129  )
130  ];
131  if ($config !== null) {
133  }
134 
135  return new Setup\ObjectiveCollection(
136  "Complete common ILIAS objectives.",
137  false,
138  ...$objectives
139  );
140  }
141 
145  public function getBuildArtifactObjective(): Setup\Objective
146  {
147  return new Setup\Objective\NullObjective();
148  }
149 
153  public function getStatusObjective(Setup\Metrics\Storage $storage): Setup\Objective
154  {
155  return new ilSetupMetricsCollectedObjective($storage);
156  }
157 
161  public function getMigrations(): array
162  {
163  return [];
164  }
165 
166  public function getNamedObjectives(?Config $config = null): array
167  {
168  return [
169  "registerNICKey" => new Setup\ObjectiveConstructor(
170  "Register NIC key",
171  static function () use ($config): Setup\Objective {
172  if (is_null($config)) {
173  throw new \RuntimeException(
174  "Missing Config for objective 'registerNICKey'."
175  );
176  }
177 
179  }
180  )
181  ];
182  }
183 }
A objective collection is a objective that is achieved once all subobjectives are achieved...
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
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: ByTrying.php:21
getUpdateObjective(Setup\Config $config=null)
There seems to already exist an ILIAS installation, an interaction with it should be confirmed...
if(!array_key_exists('PATH_INFO', $_SERVER)) $config
Definition: metadata.php:85
getInstallObjective(Setup\Config $config=null)
Data Factory $data
$objectives
__construct(Refinery\Factory $refinery, Data\Factory $data)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
An environment holds resources to be used in the setup process.
Definition: Environment.php:27
A transformation is a function from one datatype to another.
getNamedObjectives(?Config $config=null)
Refinery Factory $refinery
A configuration for the setup.
Definition: Config.php:26