ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
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
65 $this->il_setup_language->setDbHandler($db);
66
67 $installed_languages = [];
68 $local_languages = $this->il_setup_language->getLocalLanguages();
69 foreach ($this->il_setup_language->getInstalledLanguages() as $lang) {
70 $local_file = new Setup\Metrics\Metric(
71 Setup\Metrics\Metric::STABILITY_STABLE,
72 Setup\Metrics\Metric::TYPE_BOOL,
73 in_array($lang, $local_languages, true),
74 "Is there a local language file for the language?"
75 );
76 $local_changes = new Setup\Metrics\Metric(
77 Setup\Metrics\Metric::STABILITY_STABLE,
78 Setup\Metrics\Metric::TYPE_BOOL,
79 count($this->il_setup_language->getLocalChanges($lang)) > 0,
80 "Are there local changes for the language?"
81 );
82 $installed_languages[$lang] = new Setup\Metrics\Metric(
83 Setup\Metrics\Metric::STABILITY_STABLE,
84 Setup\Metrics\Metric::TYPE_COLLECTION,
85 [
86 "local_file" => $local_file,
87 "local_changes" => $local_changes
88 ]
89 );
90 }
91 $installed_languages = new Setup\Metrics\Metric(
92 Setup\Metrics\Metric::STABILITY_STABLE,
93 Setup\Metrics\Metric::TYPE_COLLECTION,
94 $installed_languages
95 );
96 $storage->store(
97 "installed_languages",
98 $installed_languages
99 );
100 }
101}
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...