ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilHttpConfigStoredObjective.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;
6 
7 class ilHttpConfigStoredObjective implements Setup\Objective
8 {
12  protected $config;
13 
14  public function __construct(
16  ) {
17  $this->config = $config;
18  }
19 
20  public function getHash() : string
21  {
22  return hash("sha256", self::class);
23  }
24 
25  public function getLabel() : string
26  {
27  return "Store configuration of Services/Http";
28  }
29 
30  public function isNotable() : bool
31  {
32  return false;
33  }
34 
35  public function getPreconditions(Setup\Environment $environment) : array
36  {
37  return [
39  new \ilSettingsFactoryExistsObjective()
40  ];
41  }
42 
43  public function achieve(Setup\Environment $environment) : Setup\Environment
44  {
45  $ini = $environment->getResource(Setup\Environment::RESOURCE_ILIAS_INI);
46 
47  $ini->setVariable("server", "http_path", $this->config->getHttpPath());
48  $ini->setVariable("https", "auto_https_detect_enabled", $this->config->isAutodetectionEnabled() ? "1" : "0");
49  $ini->setVariable("https", "auto_https_detect_header_name", $this->config->getHeaderName());
50  $ini->setVariable("https", "auto_https_detect_header_value", $this->config->getHeaderValue());
51 
52 
53  if (!$ini->write()) {
54  throw new Setup\UnachievableException("Could not write ilias.ini.php");
55  }
56 
57  $factory = $environment->getResource(Setup\Environment::RESOURCE_SETTINGS_FACTORY);
58  $settings = $factory->settingsFor("common");
59  $settings->set("proxy_status", (int) $this->config->isProxyEnabled());
60  $settings->set("proxy_host", $this->config->getProxyHost());
61  $settings->set("proxy_port", $this->config->getProxyPort());
62 
63  return $environment;
64  }
65 
69  public function isApplicable(Setup\Environment $environment) : bool
70  {
71  $ini = $environment->getResource(Setup\Environment::RESOURCE_ILIAS_INI);
72  $factory = $environment->getResource(Setup\Environment::RESOURCE_SETTINGS_FACTORY);
73  $settings = $factory->settingsFor("common");
74 
75  $detect_enabled = $this->config->isAutodetectionEnabled() ? "1" : "0";
76 
77  return
78  $ini->readVariable("server", "http_path") !== $this->config->getHttpPath() ||
79  $ini->readVariable("https", "auto_https_detect_enabled") !== $detect_enabled ||
80  $ini->readVariable("https", "auto_https_detect_header_name") !== $this->config->getHeaderName() ||
81  $ini->readVariable("https", "auto_https_detect_header_value") !== $this->config->getHeaderValue() ||
82  $settings->get("proxy_status") !== (int) $this->config->isProxyEnabled() ||
83  $settings->get("proxy_host") !== $this->config->getProxyHost() ||
84  $settings->get("proxy_port") !== $this->config->getProxyPort()
85  ;
86  }
87 }
getPreconditions(Setup\Environment $environment)
isApplicable(Setup\Environment $environment)
achieve(Setup\Environment $environment)
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
$factory
Definition: metadata.php:58
$ini
Definition: raiseError.php:4