ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilLanguagesInstalledAndUpdatedObjective.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{
13
14 public function __construct(
17 ) {
19 $this->il_setup_language = $il_setup_language;
20 }
21
22 public function getHash() : string
23 {
24 return hash("sha256", self::class);
25 }
26
27 protected function getInstallLanguages()
28 {
29 if (!is_null($this->config)) {
30 return $this->config->getInstallLanguages();
31 }
32 return $this->il_setup_language->getInstalledLanguages();
33 }
34
35 protected function getInstallLocalLanguages()
36 {
37 if (!is_null($this->config)) {
38 return $this->config->getInstallLocalLanguages();
39 }
40 return $this->il_setup_language->getInstalledLocalLanguages();
41 }
42
43 public function getLabel() : string
44 {
45 return "Install/Update languages " . implode(", ", $this->getInstallLanguages());
46 }
47
48 public function isNotable() : bool
49 {
50 return true;
51 }
52
53 public function getPreconditions(Setup\Environment $environment) : array
54 {
55 if (is_null($this->config)) {
56 return [];
57 }
58
59 $db_config = $environment->getConfigFor("database");
60 return [
61 new ilDatabasePopulatedObjective($db_config)
62 ];
63 }
64
65 public function achieve(Setup\Environment $environment) : Setup\Environment
66 {
67 $db = $environment->getResource(Setup\Environment::RESOURCE_DATABASE);
68
69 // TODO: Remove this once ilSetupLanguage (or a successor) supports proper
70 // DI for all methods.
71 $db_tmp = $GLOBALS["ilDB"];
72 $GLOBALS["ilDB"] = $db;
73
74 $this->il_setup_language->setDbHandler($db);
75 $this->il_setup_language->installLanguages(
76 $this->getInstallLanguages(),
78 );
79
80 $GLOBALS["ilDB"] = $db_tmp;
81
82 return $environment;
83 }
84
88 public function isApplicable(Setup\Environment $environment) : bool
89 {
90 return true;
91 }
92}
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
An exception for terminatinating execution or to throw for unit testing.
__construct(?\ilLanguageSetupConfig $config, \ilSetupLanguage $il_setup_language)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
An environment holds resources to be used in the setup process.
Definition: Environment.php:12
getResource(string $id)
Consumers of this method should check if the result is what they expect, e.g.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...