ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilLanguageMetricsCollectedObjective.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(
28 Setup\Metrics\Storage $storage,
30 ) {
31 parent::__construct($storage);
32 $this->il_setup_language = $il_setup_language;
33 }
34
38 protected function getTentativePreconditions(Setup\Environment $environment): array
39 {
40 return [
43 ];
44 }
45
49 protected function collectFrom(Setup\Environment $environment, Setup\Metrics\Storage $storage): void
50 {
51 $client_ini = $environment->getResource(Setup\Environment::RESOURCE_CLIENT_INI);
52 if ($client_ini) {
53 $storage->storeConfigText(
54 "default_language",
55 $client_ini->readVariable("language", "default"),
56 "The language that is used by default."
57 );
58 }
59
60 $db = $environment->getResource(Setup\Environment::RESOURCE_DATABASE);
61 if (!($db instanceof \ilDBInterface)) {
62 return;
63 }
64 $this->il_setup_language->setDbHandler($db);
65
66 // TODO: Remove this once ilSetupLanguage (or a successor) supports proper
67 // DI for all methods.
68 $GLOBALS["ilDB"] = $db;
69
70 $installed_languages = [];
71 $local_languages = $this->il_setup_language->getLocalLanguages();
72 foreach ($this->il_setup_language->getInstalledLanguages() as $lang) {
73 $local_file = new Setup\Metrics\Metric(
74 Setup\Metrics\Metric::STABILITY_STABLE,
75 Setup\Metrics\Metric::TYPE_BOOL,
76 in_array($lang, $local_languages, true),
77 "Is there a local language file for the language?"
78 );
79 $local_changes = new Setup\Metrics\Metric(
80 Setup\Metrics\Metric::STABILITY_STABLE,
81 Setup\Metrics\Metric::TYPE_BOOL,
82 count($this->il_setup_language->getLocalChanges($lang)) > 0,
83 "Are there local changes for the language?"
84 );
85 $installed_languages[$lang] = new Setup\Metrics\Metric(
86 Setup\Metrics\Metric::STABILITY_STABLE,
87 Setup\Metrics\Metric::TYPE_COLLECTION,
88 [
89 "local_file" => $local_file,
90 "local_changes" => $local_changes
91 ]
92 );
93 }
94 $installed_languages = new Setup\Metrics\Metric(
95 Setup\Metrics\Metric::STABILITY_STABLE,
96 Setup\Metrics\Metric::TYPE_COLLECTION,
97 $installed_languages
98 );
99 $storage->store(
100 "installed_languages",
101 $installed_languages
102 );
103 }
104}
A metric is something we can measure about the system.
Definition: Metric.php:34
getTentativePreconditions(Setup\Environment $environment)
@inheritDoc
__construct(Setup\Metrics\Storage $storage, \ilSetupLanguage $il_setup_language)
collectFrom(Setup\Environment $environment, Setup\Metrics\Storage $storage)
@inheritDoc
language handling for setup
An environment holds resources to be used in the setup process.
Definition: Environment.php:28
Storage is simple key/value store without further schema definition.
Definition: Storage.php:30
Interface ilDBInterface.
__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
$lang
Definition: xapiexit.php:25