ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
All Data Structures Namespaces Files Functions Variables Modules Pages
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 
5 use ILIAS\Setup;
6 
11 class ilInstallationInformationStoredObjective implements Setup\Objective
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  $common_config = $environment->getConfigFor("common");
42  return [
43  new \ilIniFilesPopulatedObjective($common_config),
44  new \ilSettingsFactoryExistsObjective()
45  ];
46  }
47 
48  public function achieve(Setup\Environment $environment) : Setup\Environment
49  {
50  $factory = $environment->getResource(Setup\Environment::RESOURCE_SETTINGS_FACTORY);
51  $common_config = $environment->getConfigFor("common");
52 
53  $settings = $factory->settingsFor("common");
54  $ini = $environment->getResource(Setup\Environment::RESOURCE_CLIENT_INI);
55 
56  $settings->set("inst_name", $this->config->getClientName());
57  $ini->setVariable("client", "name", $this->config->getClientName() ?? $common_config->getClientId());
58  $ini->setVariable("client", "description", $this->config->getClientDescription());
59  $settings->set("inst_institution", $this->config->getClientInstitution());
60  $settings->set("admin_firstname", $this->config->getContactFirstname());
61  $settings->set("admin_lastname", $this->config->getContactLastname());
62  $settings->set("admin_title", $this->config->getContactTitle());
63  $settings->set("admin_position", $this->config->getContactPosition());
64  $settings->set("admin_institution", $this->config->getContactInstitution());
65  $settings->set("admin_street", $this->config->getContactStreet());
66  $settings->set("admin_zipcode", $this->config->getContactZipcode());
67  $settings->set("admin_city", $this->config->getContactCity());
68  $settings->set("admin_country", $this->config->getContactCountry());
69  $settings->set("admin_phone", $this->config->getContactPhone());
70  $settings->set("admin_email", $this->config->getContactEMail());
71 
72  if (!$ini->write()) {
73  throw new Setup\UnachievableException("Could not write client.ini.php");
74  }
75 
76  return $environment;
77  }
78 }
An environment holds resources to be used in the setup process.
Definition: Environment.php:11
Store information about the installation, like title, description and contact information in the acco...
$factory
Definition: metadata.php:58
$ini
Definition: raiseError.php:4