ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
class.ilDefaultLanguageSetObjective.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
8{
9 public function getHash() : string
10 {
11 return hash(
12 "sha256",
13 self::class . "::" .
14 $this->config->getDefaultLanguage()
15 );
16 }
17
18 public function getLabel() : string
19 {
20 return "Set default language to " . $this->config->getDefaultLanguage();
21 }
22
23 public function isNotable() : bool
24 {
25 return true;
26 }
27
28 public function getPreconditions(Setup\Environment $environment) : array
29 {
30 $common_config = $environment->getConfigFor("common");
31 return [
32 new \ilIniFilesPopulatedObjective($common_config),
33 new \ilSettingsFactoryExistsObjective()
34 ];
35 }
36
37 public function achieve(Setup\Environment $environment) : Setup\Environment
38 {
39 $factory = $environment->getResource(Setup\Environment::RESOURCE_SETTINGS_FACTORY);
40
41 $settings = $factory->settingsFor("common");
42 $settings->set("language", $this->config->getDefaultLanguage());
43
44 $client_ini = $environment->getResource(Setup\Environment::RESOURCE_CLIENT_INI);
45 $client_ini->setVariable("language", "default", $this->config->getDefaultLanguage());
46
47 if (!$client_ini->write()) {
48 throw new Setup\UnachievableException("Could not write client.ini.php");
49 }
50
51 return $environment;
52 }
53}
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.
getPreconditions(Setup\Environment $environment)
An environment holds resources to be used in the setup process.
Definition: Environment.php:12
$factory
Definition: metadata.php:58