ILIAS  release_7 Revision v7.30-3-g800a261c036
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 return [
31 new \ilIniFilesLoadedObjective(),
32 new \ilSettingsFactoryExistsObjective()
33 ];
34 }
35
36 public function achieve(Setup\Environment $environment) : Setup\Environment
37 {
38 $factory = $environment->getResource(Setup\Environment::RESOURCE_SETTINGS_FACTORY);
39
40 $settings = $factory->settingsFor("common");
41 $settings->set("language", $this->config->getDefaultLanguage());
42
43 $client_ini = $environment->getResource(Setup\Environment::RESOURCE_CLIENT_INI);
44 $client_ini->setVariable("language", "default", $this->config->getDefaultLanguage());
45
46 if (!$client_ini->write()) {
47 throw new Setup\UnachievableException("Could not write client.ini.php");
48 }
49
50 return $environment;
51 }
52
56 public function isApplicable(Setup\Environment $environment) : bool
57 {
58 $factory = $environment->getResource(Setup\Environment::RESOURCE_SETTINGS_FACTORY);
59 $client_ini = $environment->getResource(Setup\Environment::RESOURCE_CLIENT_INI);
60 $settings = $factory->settingsFor("common");
61
62 return
63 $settings->get("language") !== $this->config->getDefaultLanguage() ||
64 $client_ini->readVariable("language", "default") !== $this->config->getDefaultLanguage()
65 ;
66 }
67}
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.
isApplicable(Setup\Environment $environment)
@inheritDoc
getPreconditions(Setup\Environment $environment)
An environment holds resources to be used in the setup process.
Definition: Environment.php:12
$factory
Definition: metadata.php:58
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...