ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilInstallationInformationStoredObjective.php
Go to the documentation of this file.
1<?php
2
19use ILIAS\Setup;
20
26{
30 protected $config;
31
32 public function __construct(
34 ) {
35 $this->config = $config;
36 }
37
38 public function getHash(): string
39 {
40 return hash("sha256", self::class);
41 }
42
43 public function getLabel(): string
44 {
45 return "Store information about installation and contact in the settings";
46 }
47
48 public function isNotable(): bool
49 {
50 return true;
51 }
52
53 public function getPreconditions(Setup\Environment $environment): array
54 {
55 return [
56 new \ilIniFilesLoadedObjective(),
57 new \ilSettingsFactoryExistsObjective()
58 ];
59 }
60
61 public function achieve(Setup\Environment $environment): Setup\Environment
62 {
63 $factory = $environment->getResource(Setup\Environment::RESOURCE_SETTINGS_FACTORY);
64 $common_config = $environment->getConfigFor("common");
65
66 $settings = $factory->settingsFor("common");
67 $ini = $environment->getResource(Setup\Environment::RESOURCE_CLIENT_INI);
68
69 $settings->set("inst_name", (string) $this->config->getClientName());
70 $ini->setVariable("client", "name", $this->config->getClientName() ?? (string) $common_config->getClientId());
71 $ini->setVariable("client", "description", (string) $this->config->getClientDescription());
72 $settings->set("inst_institution", (string) $this->config->getClientInstitution());
73 $settings->set("admin_firstname", (string) $this->config->getContactFirstname());
74 $settings->set("admin_lastname", (string) $this->config->getContactLastname());
75 $settings->set("admin_title", (string) $this->config->getContactTitle());
76 $settings->set("admin_position", (string) $this->config->getContactPosition());
77 $settings->set("admin_institution", (string) $this->config->getContactInstitution());
78 $settings->set("admin_street", (string) $this->config->getContactStreet());
79 $settings->set("admin_zipcode", (string) $this->config->getContactZipcode());
80 $settings->set("admin_city", (string) $this->config->getContactCity());
81 $settings->set("admin_country", (string) $this->config->getContactCountry());
82 $settings->set("admin_phone", (string) $this->config->getContactPhone());
83 $settings->set("admin_email", (string) $this->config->getContactEMail());
84
85 if (!$ini->write()) {
86 throw new Setup\UnachievableException("Could not write client.ini.php");
87 }
88
89 return $environment;
90 }
91
95 public function isApplicable(Setup\Environment $environment): bool
96 {
97 $factory = $environment->getResource(Setup\Environment::RESOURCE_SETTINGS_FACTORY);
98 $common_config = $environment->getConfigFor("common");
99
100 $settings = $factory->settingsFor("common");
101 $ini = $environment->getResource(Setup\Environment::RESOURCE_CLIENT_INI);
102
103 $client_name = $this->config->getClientName() ?? (string) $common_config->getClientId();
104
105 return
106 $settings->get("inst_name") !== $this->config->getClientName() ||
107 $ini->readVariable("client", "name") !== $client_name ||
108 $ini->readVariable("client", "description") !== $this->config->getClientDescription() ||
109 $settings->get("inst_institution") !== $this->config->getClientInstitution() ||
110 $settings->get("admin_firstname") !== $this->config->getContactFirstname() ||
111 $settings->get("admin_lastname") !== $this->config->getContactLastname() ||
112 $settings->get("admin_title") !== $this->config->getContactTitle() ||
113 $settings->get("admin_position") !== $this->config->getContactPosition() ||
114 $settings->get("admin_institution") !== $this->config->getContactInstitution() ||
115 $settings->get("admin_street") !== $this->config->getContactStreet() ||
116 $settings->get("admin_zipcode") !== $this->config->getContactZipcode() ||
117 $settings->get("admin_city") !== $this->config->getContactCity() ||
118 $settings->get("admin_country") !== $this->config->getContactCountry() ||
119 $settings->get("admin_phone") !== $this->config->getContactPhone() ||
120 $settings->get("admin_email") !== $this->config->getContactEMail()
121 ;
122 }
123}
Signals that some goal won't be achievable by actions of the system ever.
Store information about the installation, like title, description and contact information in the acco...
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...
$ini
Definition: raiseError.php:20