ILIAS  release_8 Revision v8.24
class.ilDefaultLanguageSetObjective.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
22use ILIAS\Setup;
23
25{
29 public function getHash(): string
30 {
31 return hash(
32 "sha256",
33 self::class . "::en"
34 );
35 }
36
40 public function getLabel(): string
41 {
42 return "Set default language to en";
43 }
44
48 public function isNotable(): bool
49 {
50 return true;
51 }
52
56 public function getPreconditions(Setup\Environment $environment): array
57 {
58 return [
59 new \ilIniFilesLoadedObjective(),
60 new \ilSettingsFactoryExistsObjective()
61 ];
62 }
63
67 public function achieve(Setup\Environment $environment): Setup\Environment
68 {
69 $factory = $environment->getResource(Setup\Environment::RESOURCE_SETTINGS_FACTORY);
70
71 $settings = $factory->settingsFor("common");
72 $settings->set("language", "en");
73
74 $client_ini = $environment->getResource(Setup\Environment::RESOURCE_CLIENT_INI);
75 $client_ini->setVariable("language", "default", "en");
76
77 if (!$client_ini->write()) {
78 throw new Setup\UnachievableException("Could not write client.ini.php");
79 }
80
81 return $environment;
82 }
83
87 public function isApplicable(Setup\Environment $environment): bool
88 {
89 $factory = $environment->getResource(Setup\Environment::RESOURCE_SETTINGS_FACTORY);
90 $client_ini = $environment->getResource(Setup\Environment::RESOURCE_CLIENT_INI);
91 $settings = $factory->settingsFor("common");
92
93 return
94 $settings->get("language") !== "en" ||
95 $client_ini->readVariable("language", "default") !== "en";
96 }
97}
Signals that some goal won't be achievable by actions of the system ever.
isApplicable(Setup\Environment $environment)
@inheritDoc
achieve(Setup\Environment $environment)
@inheritDoc
getPreconditions(Setup\Environment $environment)
@inheritDoc
An environment holds resources to be used in the setup process.
Definition: Environment.php:28
$factory
Definition: metadata.php:75
array $settings
Setting values (LTI parameters, custom parameters and local parameters).
Definition: System.php:200
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...