ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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 
32  protected $password_manager;
33 
34  public function __construct(
36  Data\Factory $data,
38  ) {
39  $this->refinery = $refinery;
40  $this->data = $data;
41  $this->password_manager = $password_manager;
42  }
43 
47  public function hasConfig() : bool
48  {
49  return true;
50  }
51 
55  public function getConfigInput(Setup\Config $config = null) : UI\Component\Input\Field\Input
56  {
57  throw new \LogicException("Not yet implemented.");
58  }
59 
64  {
65  return $this->refinery->custom()->transformation(function ($data) {
66  $password = $this->refinery->to()->data("password");
67  $datetimezone = $this->refinery->to()->toNew(\DateTimeZone::class);
68  return new \ilSetupConfig(
69  $data["client_id"],
70  $password->transform($data["master_password"]),
71  $datetimezone->transform([$data["server_timezone"] ?? "UTC"]),
72  $data["register_nic"] ?? false
73  );
74  });
75  }
76 
80  public function getInstallObjective(Setup\Config $config = null) : Setup\Objective
81  {
82  return new Setup\ObjectiveWithPreconditions(
85  new Setup\ObjectiveCollection(
86  "Complete common ILIAS objectives.",
87  false,
88  new Setup\PHPVersionCondition("7.2.0"),
89  new Setup\PHPExtensionLoadedCondition("dom"),
90  new Setup\PHPExtensionLoadedCondition("xsl"),
91  new Setup\PHPExtensionLoadedCondition("gd"),
93  new ilSetupConfigStoredObjective($config, $this->password_manager),
94  $config->getRegisterNIC()
97  )
98  );
99  }
100 
101  protected function getPHPMemoryLimitCondition() : Setup\Objective
102  {
103  return new Setup\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  return new Setup\NullObjective();
124  }
125 
129  public function getBuildArtifactObjective() : Setup\Objective
130  {
131  return new Setup\NullObjective();
132  }
133 }
A objective collection is a objective that is achieved once all subobjectives are achieved...
Contains common objectives for the setup.
Class Factory.
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)
getConfigInput(Setup\Config $config=null)
Builds data types.
Definition: Factory.php:19
$password
Definition: cron.php:14
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
__construct(Refinery\Factory $refinery, Data\Factory $data, \ilSetupPasswordManager $password_manager)
Class ilSetupPasswordManager.