ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
class.ilLanguagesInstalledObjective.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(
25 "sha256",
26 self::class . "::" .
27 $this->getInstallLanguagesAsString() . "::" .
29 );
30 }
31
32 protected function getInstallLanguagesAsString()
33 {
34 return implode(", ", $this->config->getInstallLanguages());
35 }
36
38 {
39 return implode(", ", $this->config->getInstallLocalLanguages());
40 }
41
42 public function getLabel() : string
43 {
44 return "Install languages " . $this->getInstallLanguagesAsString();
45 }
46
47 public function isNotable() : bool
48 {
49 return true;
50 }
51
52 public function getPreconditions(Setup\Environment $environment) : array
53 {
54 $db_config = $environment->getConfigFor("database");
55 return [
56 new ilDatabasePopulatedObjective($db_config)
57 ];
58 }
59
60 public function achieve(Setup\Environment $environment) : Setup\Environment
61 {
62 $db = $environment->getResource(Setup\Environment::RESOURCE_DATABASE);
63
64 // TODO: Remove this once ilSetupLanguage (or a successor) supports proper
65 // DI for all methods.
66 $GLOBALS["ilDB"] = $db;
67
68 $this->il_setup_language->setDbHandler($db);
69 $this->il_setup_language->installLanguages(
70 $this->config->getInstallLanguages(),
71 $this->config->getInstallLocalLanguages()
72 );
73
74 return $environment;
75 }
76}
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
An exception for terminatinating execution or to throw for unit testing.
getPreconditions(Setup\Environment $environment)
__construct(\ilLanguageSetupConfig $config, \ilSetupLanguage $il_setup_language)
language handling for setup
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