ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilCommonSetupAgent.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21use ILIAS\Setup;
23use ILIAS\Data;
25
32{
33 private const PHP_MEMORY_LIMIT = "128M";
34 private const PHP_MIN_VERSION = "8.3.0";
35 private const PHP_MAX_VERSION = "8.4.999";
36
37 protected Refinery\Factory $refinery;
38 protected Data\Factory $data;
39
40 public function __construct(
43 ) {
44 $this->refinery = $refinery;
45 $this->data = $data;
46 }
47
51 public function hasConfig(): bool
52 {
53 return true;
54 }
55
60 {
61 return $this->refinery->custom()->transformation(function ($data) {
62 $export_hooks_path = null;
63 if (key_exists("export_hooks_path", $data)) {
64 $export_hooks_path = $data["export_hooks_path"];
65 }
66 $datetimezone = $this->refinery->to()->toNew(\DateTimeZone::class);
67 return new \ilSetupConfig(
68 $this->data->clientId($data["client_id"] ?? ''),
69 $datetimezone->transform([$data["server_timezone"] ?? "UTC"]),
70 $data["register_nic"] ?? false,
71 $export_hooks_path
72 );
73 });
74 }
75
79 public function getInstallObjective(?Setup\Config $config = null): Setup\Objective
80 {
85 "Complete common ILIAS objectives.",
86 false,
87 new Setup\Condition\PHPVersionCondition(self::PHP_MIN_VERSION, self::PHP_MAX_VERSION, true),
88 new Setup\Condition\PHPExtensionLoadedCondition("dom"),
89 new Setup\Condition\PHPExtensionLoadedCondition("xsl"),
90 new Setup\Condition\PHPExtensionLoadedCondition("gd"),
94 )
95 );
96 }
97
99 {
101 "PHP memory limit >= " . self::PHP_MEMORY_LIMIT,
102 function (Setup\Environment $env): bool {
103 $limit = ini_get("memory_limit");
104 if ($limit == -1) {
105 return true;
106 }
107 $expected = $this->data->dataSize(self::PHP_MEMORY_LIMIT);
108 $current = $this->data->dataSize($limit);
109 return $current->inBytes() >= $expected->inBytes();
110 },
111 "To properly execute ILIAS, please take care that the PHP memory limit is at least set to 128M."
112 );
113 }
114
118 public function getUpdateObjective(?Setup\Config $config = null): Setup\Objective
119 {
120 $objectives = [
123 new Setup\Condition\PHPVersionCondition(self::PHP_MIN_VERSION, self::PHP_MAX_VERSION, true),
126 )
127 ];
128
129 if ($config !== null) {
132 }
133
134 return new Setup\ObjectiveCollection(
135 "Complete common ILIAS objectives.",
136 false,
137 ...$objectives
138 );
139 }
140
145 {
147 }
148
152 public function getStatusObjective(Setup\Metrics\Storage $storage): Setup\Objective
153 {
154 return new ilSetupMetricsCollectedObjective($storage);
155 }
156
160 public function getMigrations(): array
161 {
162 return [];
163 }
164
165 public function getNamedObjectives(?Config $config = null): array
166 {
167 return [
168 "registerNICKey" => new Setup\ObjectiveConstructor(
169 "Register NIC key",
170 static function () use ($config): Setup\Objective {
171 if (is_null($config)) {
172 throw new \RuntimeException(
173 "Missing Config for objective 'registerNICKey'."
174 );
175 }
176
177 return new ilNICKeyRegisteredObjective($config);
178 }
179 ),
180 "buildExportZip" => new Setup\ObjectiveConstructor(
181 "Build ILIAS export zip",
182 static function () use ($config): Setup\Objective {
183 if (is_null($config)) {
184 throw new \RuntimeException(
185 "Missing Config for objective 'buildExportZip'."
186 );
187 }
188 return new ilExportZipBuiltObjective($config);
189 }
190 )
191 ];
192 }
193}
Builds a Color from either hex- or rgb values.
Definition: Factory.php:31
A condition that can't be met by ILIAS itself needs to be met by some external means.
A objective collection is a objective that is achieved once all subobjectives are achieved.
A non-objective, nothing to do to achieve it...
A wrapper around an objective that adds some preconditions.
Contains common objectives for the setup.
__construct(Refinery\Factory $refinery, Data\Factory $data)
getUpdateObjective(?Setup\Config $config=null)
getStatusObjective(Setup\Metrics\Storage $storage)
getInstallObjective(?Setup\Config $config=null)
getNamedObjectives(?Config $config=null)
There seems to already exist an ILIAS installation, an interaction with it should be confirmed.
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 environment holds resources to be used in the setup process.
Definition: Environment.php:28
An objective is a desired state of the system that is supposed to be created by the setup.
Definition: Objective.php:31
Storage is simple key/value store without further schema definition.
Definition: Storage.php:30
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$objectives