ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilDefaultLanguageSetObjective.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21use ILIAS\Setup;
22
24{
28 public function getHash(): string
29 {
30 return hash(
31 "sha256",
32 self::class . "::en"
33 );
34 }
35
39 public function getLabel(): string
40 {
41 return "Set default language to en";
42 }
43
47 public function isNotable(): bool
48 {
49 return true;
50 }
51
55 public function getPreconditions(Setup\Environment $environment): array
56 {
57 return [
58 new \ilIniFilesLoadedObjective(),
59 new \ilSettingsFactoryExistsObjective()
60 ];
61 }
62
66 public function achieve(Setup\Environment $environment): Setup\Environment
67 {
68 $factory = $environment->getResource(Setup\Environment::RESOURCE_SETTINGS_FACTORY);
69
70 $settings = $factory->settingsFor("common");
71 $settings->set("language", "en");
72
73 $client_ini = $environment->getResource(Setup\Environment::RESOURCE_CLIENT_INI);
74 $client_ini->setVariable("language", "default", "en");
75
76 if (!$client_ini->write()) {
77 throw new Setup\UnachievableException("Could not write client.ini.php");
78 }
79
80 return $environment;
81 }
82
86 public function isApplicable(Setup\Environment $environment): bool
87 {
88 $factory = $environment->getResource(Setup\Environment::RESOURCE_SETTINGS_FACTORY);
89 $client_ini = $environment->getResource(Setup\Environment::RESOURCE_CLIENT_INI);
90 $settings = $factory->settingsFor("common");
91
92 return
93 $settings->get("language") !== "en" ||
94 $client_ini->readVariable("language", "default") !== "en";
95 }
96}
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
getResource(string $id)
Consumers of this method should check if the result is what they expect, e.g.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...