ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilSetupAgent.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 2019 Richard Klees <richard.klees@concepts-and-training.de> Extended GPL, see docs/LICENSE */
4 
5 use ILIAS\Setup;
7 use ILIAS\Data;
8 use ILIAS\UI;
9 
15 class ilSetupAgent implements Setup\Agent
16 {
17  const PHP_MEMORY_LIMIT = "128M";
18 
22  protected $refinery;
23 
27  protected $data;
28 
29  public function __construct(
31  Data\Factory $data
32  ) {
33  $this->refinery = $refinery;
34  $this->data = $data;
35  }
36 
40  public function hasConfig() : bool
41  {
42  return true;
43  }
44 
49  {
50  return $this->refinery->custom()->transformation(function ($data) {
51  $datetimezone = $this->refinery->to()->toNew(\DateTimeZone::class);
52  return new \ilSetupConfig(
53  $this->data->clientId($data["client_id"] ?? ''),
54  $datetimezone->transform([$data["server_timezone"] ?? "UTC"]),
55  $data["register_nic"] ?? false
56  );
57  });
58  }
59 
63  public function getInstallObjective(Setup\Config $config = null) : Setup\Objective
64  {
65  return new Setup\Objective\ObjectiveWithPreconditions(
68  new Setup\ObjectiveCollection(
69  "Complete common ILIAS objectives.",
70  false,
71  new Setup\Condition\PHPVersionCondition("7.2.0"),
72  new Setup\Condition\PHPExtensionLoadedCondition("dom"),
73  new Setup\Condition\PHPExtensionLoadedCondition("xsl"),
74  new Setup\Condition\PHPExtensionLoadedCondition("gd"),
77  $config->getRegisterNIC()
79  : new Setup\ObjectiveCollection(
80  "",
81  false,
84  )
85  )
86  );
87  }
88 
89  protected function getPHPMemoryLimitCondition() : Setup\Objective
90  {
91  return new Setup\Condition\ExternalConditionObjective(
92  "PHP memory limit >= " . self::PHP_MEMORY_LIMIT,
93  function (Setup\Environment $env) : bool {
94  $limit = ini_get("memory_limit");
95  if ($limit == -1) {
96  return true;
97  }
98  $expected = $this->data->dataSize(self::PHP_MEMORY_LIMIT);
99  $current = $this->data->dataSize($limit);
100  return $current->inBytes() >= $expected->inBytes();
101  },
102  "To properly execute ILIAS, please take care that the PHP memory limit is at least set to 128M."
103  );
104  }
105 
109  public function getUpdateObjective(Setup\Config $config = null) : Setup\Objective
110  {
111  if ($config !== null) {
113  }
114  return new Setup\Objective\NullObjective();
115  }
116 
120  public function getBuildArtifactObjective() : Setup\Objective
121  {
122  return new Setup\Objective\NullObjective();
123  }
124 
128  public function getStatusObjective(Setup\Metrics\Storage $storage) : Setup\Objective
129  {
130  return new ilSetupMetricsCollectedObjective($storage);
131  }
132 
136  public function getMigrations() : array
137  {
138  return [];
139  }
140 
141 
142  public function getNamedObjective(string $name, Setup\Config $config = null) : Setup\Objective
143  {
144  if ($name == "registerNICKey") {
145  if (is_null($config)) {
146  throw new \RuntimeException(
147  "Missing Config for objective '$name'."
148  );
149  }
151  }
152  throw new \InvalidArgumentException(
153  "There is no named objective '$name'"
154  );
155  }
156 }
A objective collection is a objective that is achieved once all subobjectives are achieved...
Contains common objectives for the setup.
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:14
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:68
getInstallObjective(Setup\Config $config=null)
if($format !==null) $name
Definition: metadata.php:230
getNamedObjective(string $name, Setup\Config $config=null)
__construct(Refinery\Factory $refinery, Data\Factory $data)
Builds data types.
Definition: Factory.php:19
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:11
A transformation is a function from one datatype to another.
A configuration for the setup.
Definition: Config.php:10