ILIAS  release_8 Revision v8.24
class.ilSetupAgent.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21use ILIAS\Setup;
23use ILIAS\Data;
26
32class 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;
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 {
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 {
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 = [
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 {
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}
Builds data types.
Definition: Factory.php:21
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.
There seems to already exist an ILIAS installation, an interaction with it should be confirmed.
Contains common objectives for the setup.
getNamedObjectives(?Config $config=null)
getInstallObjective(Setup\Config $config=null)
Refinery Factory $refinery
__construct(Refinery\Factory $refinery, Data\Factory $data)
getStatusObjective(Setup\Metrics\Storage $storage)
getUpdateObjective(Setup\Config $config=null)
Data Factory $data
getMigrations()
@inheritDoc
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
if(!array_key_exists('PATH_INFO', $_SERVER)) $config
Definition: metadata.php:85
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: ByTrying.php:21
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$objectives