ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilHttpConfigStoredObjective.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21use ILIAS\Setup;
22
24{
25 protected \ilHttpSetupConfig $config;
26
27 public function __construct(
29 ) {
30 $this->config = $config;
31 }
32
33 public function getHash(): string
34 {
35 return hash("sha256", self::class);
36 }
37
38 public function getLabel(): string
39 {
40 return "Store configuration of Services/Http";
41 }
42
43 public function isNotable(): bool
44 {
45 return false;
46 }
47
51 public function getPreconditions(Setup\Environment $environment): array
52 {
53 return [
55 new \ilSettingsFactoryExistsObjective()
56 ];
57 }
58
59 public function achieve(Setup\Environment $environment): Setup\Environment
60 {
61 $ini = $environment->getResource(Setup\Environment::RESOURCE_ILIAS_INI);
62
63 $ini->setVariable(
66 $this->config->getHttpPath()
67 );
68 $ini->setVariable(
71 $this->config->isForced() ? "1" : "0"
72 );
73 $ini->setVariable(
76 $this->config->isAutodetectionEnabled() ? "1" : "0"
77 );
78 $ini->setVariable(
81 (string) $this->config->getHeaderName()
82 );
83 $ini->setVariable(
86 (string) $this->config->getHeaderValue()
87 );
88
89
90 if (!$ini->write()) {
91 throw new Setup\UnachievableException("Could not write ilias.ini.php");
92 }
93
94 $factory = $environment->getResource(Setup\Environment::RESOURCE_SETTINGS_FACTORY);
95 $settings = $factory->settingsFor("common");
96 $settings->set("proxy_status", (string) $this->config->isProxyEnabled());
97 $settings->set("proxy_host", (string) $this->config->getProxyHost());
98 $settings->set("proxy_port", (string) $this->config->getProxyPort());
99
100 if (is_array($this->config->getAllowedHosts()) && $this->config->getAllowedHosts() !== []) {
101 $settings->set('allowed_hosts', implode(',', $this->config->getAllowedHosts()));
102 } else {
103 $settings->delete('allowed_hosts');
104 }
105
106 return $environment;
107 }
108
112 public function isApplicable(Setup\Environment $environment): bool
113 {
114 $ini = $environment->getResource(Setup\Environment::RESOURCE_ILIAS_INI);
115 $factory = $environment->getResource(Setup\Environment::RESOURCE_SETTINGS_FACTORY);
116 $settings = $factory->settingsFor("common");
117
118 $detect_enabled = $this->config->isAutodetectionEnabled() ? "1" : "0";
119 $forced = $this->config->isForced() ? "1" : "0";
120
121 return
122 $ini->readVariable(ilHTTPS::SETTINGS_GROUP_SERVER, ilHTTPS::SETTING_HTTP_PATH) !== $this->config->getHttpPath() ||
124 $ini->readVariable(ilHTTPS::SETTINGS_GROUP_HTTPS, ilHTTPS::SETTING_FORCED) !== $forced ||
125 $ini->readVariable(ilHTTPS::SETTINGS_GROUP_HTTPS, ilHTTPS::SETTING_AUTO_HTTPS_DETECT_HEADER_NAME) !== $this->config->getHeaderName() ||
126 $ini->readVariable(ilHTTPS::SETTINGS_GROUP_HTTPS, ilHTTPS::SETTING_AUTO_HTTPS_DETECT_HEADER_VALUE) !== $this->config->getHeaderValue() ||
127 $settings->get("proxy_status") !== (int) $this->config->isProxyEnabled() ||
128 $settings->get("proxy_host") !== $this->config->getProxyHost() ||
129 $settings->get("proxy_port") !== $this->config->getProxyPort() ||
130 $settings->get('allowed_hosts', '') !== implode(',', $this->config->getAllowedHosts() ?? [])
131 ;
132 }
133}
Signals that some goal won't be achievable by actions of the system ever.
const SETTINGS_GROUP_SERVER
const SETTING_HTTP_PATH
const SETTINGS_GROUP_HTTPS
const SETTING_AUTO_HTTPS_DETECT_HEADER_VALUE
const SETTING_AUTO_HTTPS_DETECT_ENABLED
const SETTING_AUTO_HTTPS_DETECT_HEADER_NAME
const SETTING_FORCED
isApplicable(Setup\Environment $environment)
@inheritDoc
achieve(Setup\Environment $environment)
getPreconditions(Setup\Environment $environment)
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
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$ini
Definition: raiseError.php:20