ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilInstallationInformationStoredObjective.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
6
12{
16 protected $config;
17
18 public function __construct(
20 ) {
21 $this->config = $config;
22 }
23
24 public function getHash() : string
25 {
26 return hash("sha256", self::class);
27 }
28
29 public function getLabel() : string
30 {
31 return "Store information about installation and contact in the settings";
32 }
33
34 public function isNotable() : bool
35 {
36 return true;
37 }
38
39 public function getPreconditions(Setup\Environment $environment) : array
40 {
41 return [
42 new \ilIniFilesLoadedObjective(),
43 new \ilSettingsFactoryExistsObjective()
44 ];
45 }
46
47 public function achieve(Setup\Environment $environment) : Setup\Environment
48 {
49 $factory = $environment->getResource(Setup\Environment::RESOURCE_SETTINGS_FACTORY);
50 $common_config = $environment->getConfigFor("common");
51
52 $settings = $factory->settingsFor("common");
53 $ini = $environment->getResource(Setup\Environment::RESOURCE_CLIENT_INI);
54
55 $settings->set("inst_name", $this->config->getClientName());
56 $ini->setVariable("client", "name", $this->config->getClientName() ?? $common_config->getClientId());
57 $ini->setVariable("client", "description", $this->config->getClientDescription());
58 $settings->set("inst_institution", $this->config->getClientInstitution());
59 $settings->set("admin_firstname", $this->config->getContactFirstname());
60 $settings->set("admin_lastname", $this->config->getContactLastname());
61 $settings->set("admin_title", $this->config->getContactTitle());
62 $settings->set("admin_position", $this->config->getContactPosition());
63 $settings->set("admin_institution", $this->config->getContactInstitution());
64 $settings->set("admin_street", $this->config->getContactStreet());
65 $settings->set("admin_zipcode", $this->config->getContactZipcode());
66 $settings->set("admin_city", $this->config->getContactCity());
67 $settings->set("admin_country", $this->config->getContactCountry());
68 $settings->set("admin_phone", $this->config->getContactPhone());
69 $settings->set("admin_email", $this->config->getContactEMail());
70
71 if (!$ini->write()) {
72 throw new Setup\UnachievableException("Could not write client.ini.php");
73 }
74
75 return $environment;
76 }
77
81 public function isApplicable(Setup\Environment $environment) : bool
82 {
83 $factory = $environment->getResource(Setup\Environment::RESOURCE_SETTINGS_FACTORY);
84 $common_config = $environment->getConfigFor("common");
85
86 $settings = $factory->settingsFor("common");
87 $ini = $environment->getResource(Setup\Environment::RESOURCE_CLIENT_INI);
88
89 $client_name = $this->config->getClientName() ?? $common_config->getClientId();
90
91 return
92 $settings->get("inst_name") !== $this->config->getClientName() ||
93 $ini->readVariable("client", "name") !== $client_name ||
94 $ini->readVariable("client", "description") !== $this->config->getClientDescription() ||
95 $settings->get("inst_institution") !== $this->config->getClientInstitution() ||
96 $settings->get("admin_firstname") !== $this->config->getContactFirstname() ||
97 $settings->get("admin_lastname") !== $this->config->getContactLastname() ||
98 $settings->get("admin_title") !== $this->config->getContactTitle() ||
99 $settings->get("admin_position") !== $this->config->getContactPosition() ||
100 $settings->get("admin_institution") !== $this->config->getContactInstitution() ||
101 $settings->get("admin_street") !== $this->config->getContactStreet() ||
102 $settings->get("admin_zipcode") !== $this->config->getContactZipcode() ||
103 $settings->get("admin_city") !== $this->config->getContactCity() ||
104 $settings->get("admin_country") !== $this->config->getContactCountry() ||
105 $settings->get("admin_phone") !== $this->config->getContactPhone() ||
106 $settings->get("admin_email") !== $this->config->getContactEMail()
107 ;
108 }
109}
An exception for terminatinating execution or to throw for unit testing.
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:12
An objective is a desired state of the system that is supposed to be created by the setup.
Definition: Objective.php:15
$factory
Definition: metadata.php:58
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$ini
Definition: raiseError.php:4