ILIAS  release_8 Revision v8.24
class.ilHttpConfigStoredObjective.php
Go to the documentation of this file.
1<?php
2
4
5/******************************************************************************
6 *
7 * This file is part of ILIAS, a powerful learning management system.
8 *
9 * ILIAS is licensed with the GPL-3.0, you should have received a copy
10 * of said license along with the source code.
11 *
12 * If this is not the case or you just want to try ILIAS, you'll find
13 * us at:
14 * https://www.ilias.de
15 * https://github.com/ILIAS-eLearning
16 *
17 *****************************************************************************/
19{
20 protected \ilHttpSetupConfig $config;
21
22 public function __construct(
24 ) {
25 $this->config = $config;
26 }
27
28 public function getHash(): string
29 {
30 return hash("sha256", self::class);
31 }
32
33 public function getLabel(): string
34 {
35 return "Store configuration of Services/Http";
36 }
37
38 public function isNotable(): bool
39 {
40 return false;
41 }
42
46 public function getPreconditions(Setup\Environment $environment): array
47 {
48 return [
50 new \ilSettingsFactoryExistsObjective()
51 ];
52 }
53
54 public function achieve(Setup\Environment $environment): Setup\Environment
55 {
56 $ini = $environment->getResource(Setup\Environment::RESOURCE_ILIAS_INI);
57
58 $ini->setVariable(
61 $this->config->getHttpPath()
62 );
63 $ini->setVariable(
66 $this->config->isForced() ? "1" : "0"
67 );
68 $ini->setVariable(
71 $this->config->isAutodetectionEnabled() ? "1" : "0"
72 );
73 $ini->setVariable(
76 (string) $this->config->getHeaderName()
77 );
78 $ini->setVariable(
81 (string) $this->config->getHeaderValue()
82 );
83
84
85 if (!$ini->write()) {
86 throw new Setup\UnachievableException("Could not write ilias.ini.php");
87 }
88
89 $factory = $environment->getResource(Setup\Environment::RESOURCE_SETTINGS_FACTORY);
90 $settings = $factory->settingsFor("common");
91 $settings->set("proxy_status", (string) $this->config->isProxyEnabled());
92 $settings->set("proxy_host", (string) $this->config->getProxyHost());
93 $settings->set("proxy_port", (string) $this->config->getProxyPort());
94
95 return $environment;
96 }
97
101 public function isApplicable(Setup\Environment $environment): bool
102 {
103 $ini = $environment->getResource(Setup\Environment::RESOURCE_ILIAS_INI);
104 $factory = $environment->getResource(Setup\Environment::RESOURCE_SETTINGS_FACTORY);
105 $settings = $factory->settingsFor("common");
106
107 $detect_enabled = $this->config->isAutodetectionEnabled() ? "1" : "0";
108 $forced = $this->config->isForced() ? "1" : "0";
109
110 return
111 $ini->readVariable(ilHTTPS::SETTINGS_GROUP_SERVER, ilHTTPS::SETTING_HTTP_PATH) !== $this->config->getHttpPath() ||
113 $ini->readVariable(ilHTTPS::SETTINGS_GROUP_HTTPS, ilHTTPS::SETTING_FORCED) !== $forced ||
114 $ini->readVariable(ilHTTPS::SETTINGS_GROUP_HTTPS, ilHTTPS::SETTING_AUTO_HTTPS_DETECT_HEADER_NAME) !== $this->config->getHeaderName() ||
115 $ini->readVariable(ilHTTPS::SETTINGS_GROUP_HTTPS, ilHTTPS::SETTING_AUTO_HTTPS_DETECT_HEADER_VALUE) !== $this->config->getHeaderValue() ||
116 $settings->get("proxy_status") !== (int) $this->config->isProxyEnabled() ||
117 $settings->get("proxy_host") !== $this->config->getProxyHost() ||
118 $settings->get("proxy_port") !== $this->config->getProxyPort()
119 ;
120 }
121}
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
$factory
Definition: metadata.php:75
array $settings
Setting values (LTI parameters, custom parameters and local parameters).
Definition: System.php:200
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$ini
Definition: raiseError.php:4