ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilLanguagesUpdatedObjective.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
22 use ILIAS\Setup;
23 
24 class ilLanguagesUpdatedObjective implements Setup\Objective
25 {
26  protected \ilSetupLanguage $il_setup_language;
27 
28  public function __construct(
29  \ilSetupLanguage $il_setup_language
30  ) {
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 getInstalledLanguagesAsString(): string
46  {
47  return implode(", ", $this->il_setup_language->getInstalledLanguages());
48  }
49 
53  public function getLabel(): string
54  {
55  return "Update languages " . $this->getInstalledLanguagesAsString();
56  }
57 
61  public function isNotable(): bool
62  {
63  return true;
64  }
65 
69  public function getPreconditions(Setup\Environment $environment): array
70  {
71  return [];
72  }
73 
77  public function achieve(Setup\Environment $environment): Setup\Environment
78  {
79  $db = $environment->getResource(Setup\Environment::RESOURCE_DATABASE);
80 
81  // TODO: Remove this once ilSetupLanguage (or a successor) supports proper
83  $db_tmp = $GLOBALS["ilDB"];
84  $GLOBALS["ilDB"] = $db;
85 
86  $this->il_setup_language->setDbHandler($db);
87  $this->il_setup_language->installLanguages(
88  $this->il_setup_language->getInstalledLanguages(),
89  $this->il_setup_language->getLocalLanguages()
90  );
91 
92  $GLOBALS["ilDB"] = $db_tmp;
93 
94  return $environment;
95  }
96 
100  public function isApplicable(Setup\Environment $environment): bool
101  {
102  return true;
103  }
104 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
achieve(Setup\Environment $environment)
__construct(\ilSetupLanguage $il_setup_language)
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
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...
An environment holds resources to be used in the setup process.
Definition: Environment.php:27
isApplicable(Setup\Environment $environment)
getInstalledLanguagesAsString()
Return installed languages as string.
getPreconditions(Setup\Environment $environment)