ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilChatroomServerConfigStoredObjective.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21use ILIAS\DI;
22use ILIAS\Setup;
23
25{
26 public function __construct(protected ilChatroomSetupConfig $config)
27 {
28 }
29
30 public function getHash(): string
31 {
32 return hash("sha256", self::class);
33 }
34
35 public function getLabel(): string
36 {
37 return "Store information about chatroom server to db";
38 }
39
40 public function isNotable(): bool
41 {
42 return true;
43 }
44
45 public function getPreconditions(Setup\Environment $environment): array
46 {
47 return [
51 ];
52 }
53
54 public function achieve(Setup\Environment $environment): Setup\Environment
55 {
56 $db = $environment->getResource(Setup\Environment::RESOURCE_DATABASE);
57 $common_config = $environment->getConfigFor("common");
58 $filesystem_config = $environment->getConfigFor("filesystem");
59
60 // ATTENTION: This is a total abomination. It only exists to allow various
61 // sub components of the various readers to run. This is a memento to the
62 // fact, that dependency injection is something we want. Currently, every
63 // component could just service locate the whole world via the global $DIC.
64 $DIC = $GLOBALS["DIC"];
65 $GLOBALS["DIC"] = new DI\Container();
66 $GLOBALS["DIC"]["ilDB"] = $db;
67 $GLOBALS["DIC"]["ilBench"] = null;
68
69 $chatAdministrations = ilObject::_getObjectsByType('chta');
70 $chatAdministration = current($chatAdministrations);
71
72 $chat_admin = new ilChatroomAdmin((int) $chatAdministration['obj_id']);
73 $settings = $chat_admin->loadGeneralSettings();
74
75 $settings['address'] = $this->config->getAddress();
76 $settings['port'] = $this->config->getPort();
77 $settings['sub_directory'] = $this->config->getSubDirectory();
78 $settings['protocol'] = $this->config->getProtocol();
79 $settings['cert'] = $this->config->getCert();
80 $settings['key'] = $this->config->getKey();
81 $settings['dhparam'] = $this->config->getDhparam();
82 $settings['log'] = $this->config->getLog();
83 $settings['log_level'] = $this->config->getLogLevel();
84 $settings['error_log'] = $this->config->getErrorLog();
85 $settings['ilias_proxy'] = (int) $this->config->hasIliasProxy();
86 $settings['ilias_url'] = $this->config->getIliasUrl();
87 $settings['client_proxy'] = (int) $this->config->hasClientProxy();
88 $settings['client_url'] = $this->config->getClientUrl();
89 $settings['deletion_mode'] = (int) $this->config->hasDeletionMode();
90 $settings['deletion_unit'] = $this->config->getDeletionUnit();
91 $settings['deletion_value'] = $this->config->getDeletionValue();
92 $settings['deletion_time'] = $this->config->getDeletionTime();
93
94 $chat_admin->saveGeneralSettings((object) $settings);
95
96 if (!defined("CLIENT_DATA_DIR")) {
97 define(
98 "CLIENT_DATA_DIR",
99 $filesystem_config->getDataDir() . "/" . ((string) $common_config->getClientId())
100 );
101 }
102
103 $fileHandler = new ilChatroomConfigFileHandler();
104 $fileHandler->createServerConfigFile($settings);
105
106 $GLOBALS["DIC"] = $DIC;
107
108 return $environment;
109 }
110
111 public function isApplicable(Setup\Environment $environment): bool
112 {
113 return $this->config->getAddress() !== '' && $this->config->getPort() > 0;
114 }
115}
Customizing of pimple-DIC for ILIAS.
Definition: Container.php:36
Class ilChatroomAdmin.
static _getObjectsByType(string $obj_type="", ?int $owner=null)
An environment holds resources to be used in the setup process.
Definition: Environment.php:28
getResource(string $id)
Consumers of this method should check if the result is what they expect, e.g.
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...
Definition: Container.php:19
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $DIC
Definition: shib_login.php:26
$GLOBALS["DIC"]
Definition: wac.php:54