ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilLanguagesInstalledAndUpdatedObjective.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21use ILIAS\Setup;
22
24{
25 protected \ilSetupLanguage $il_setup_language;
26
27 public function __construct(
29 ) {
31 $this->il_setup_language = $il_setup_language;
32 }
33
37 public function getHash(): string
38 {
39 return hash("sha256", self::class);
40 }
41
45 protected function getInstallLanguages(): array
46 {
47 return $this->il_setup_language->getInstalledLanguages() ?: ['en'];
48 }
49
53 protected function getInstallLocalLanguages(): array
54 {
55 return $this->il_setup_language->getInstalledLocalLanguages();
56 }
57
61 public function getLabel(): string
62 {
63 return "Install/Update languages " . implode(", ", $this->getInstallLanguages());
64 }
65
69 public function isNotable(): bool
70 {
71 return true;
72 }
73
77 public function getPreconditions(Setup\Environment $environment): array
78 {
79 return [
81 ];
82 }
83
87 public function achieve(Setup\Environment $environment): Setup\Environment
88 {
89 $db = $environment->getResource(Setup\Environment::RESOURCE_DATABASE);
90
91 // TODO: Remove this once ilSetupLanguage (or a successor) supports proper
92 // DI for all methods.
93 $db_tmp = $GLOBALS["ilDB"];
94 $GLOBALS["ilDB"] = $db;
95
96 $this->il_setup_language->setDbHandler($db);
97 $this->il_setup_language->installLanguages(
98 $this->getInstallLanguages(),
100 );
101
102 $GLOBALS["ilDB"] = $db_tmp;
103
104 return $environment;
105 }
106
110 public function isApplicable(Setup\Environment $environment): bool
111 {
112 return true;
113 }
114}
language handling for setup
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.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$GLOBALS["DIC"]
Definition: wac.php:54