ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilLanguageMetricsCollectedObjective.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 2020 Richard Klees <richard.klees@concepts-and-training.de> Extended GPL, see docs/LICENSE */
4
6
8{
13
14 public function __construct(
15 Setup\Metrics\Storage $storage,
17 ) {
18 parent::__construct($storage);
19 $this->il_setup_language = $il_setup_language;
20 }
21
22
23 public function getTentativePreconditions(Setup\Environment $environment) : array
24 {
25 return [
28 ];
29 }
30
31 public function collectFrom(Setup\Environment $environment, Setup\Metrics\Storage $storage) : void
32 {
33 $client_ini = $environment->getResource(Setup\Environment::RESOURCE_CLIENT_INI);
34 if ($client_ini) {
35 $storage->storeConfigText(
36 "default_language",
37 $client_ini->readVariable("language", "default"),
38 "The language that is used by default."
39 );
40 }
41
42 $db = $environment->getResource(Setup\Environment::RESOURCE_DATABASE);
43 if (!($db instanceof \ilDBInterface)) {
44 return;
45 }
46 $this->il_setup_language->setDbHandler($db);
47
48 // TODO: Remove this once ilSetupLanguage (or a successor) supports proper
49 // DI for all methods.
50 $GLOBALS["ilDB"] = $db;
51
52 $installed_languages = [];
53 $local_languages = $this->il_setup_language->getLocalLanguages();
54 foreach ($this->il_setup_language->getInstalledLanguages() as $lang) {
55 $local_file = new Setup\Metrics\Metric(
56 Setup\Metrics\Metric::STABILITY_STABLE,
57 Setup\Metrics\Metric::TYPE_BOOL,
58 in_array($lang, $local_languages),
59 "Is there a local language file for the language?"
60 );
61 $local_changes = new Setup\Metrics\Metric(
62 Setup\Metrics\Metric::STABILITY_STABLE,
63 Setup\Metrics\Metric::TYPE_BOOL,
64 count($this->il_setup_language->getLocalChanges($lang)) > 0,
65 "Are there local changes for the language?"
66 );
67 $installed_languages[$lang] = new Setup\Metrics\Metric(
68 Setup\Metrics\Metric::STABILITY_STABLE,
69 Setup\Metrics\Metric::TYPE_COLLECTION,
70 [
71 "local_file" => $local_file,
72 "local_changes" => $local_changes
73 ]
74 );
75 };
76 $installed_languages = new Setup\Metrics\Metric(
77 Setup\Metrics\Metric::STABILITY_STABLE,
78 Setup\Metrics\Metric::TYPE_COLLECTION,
79 $installed_languages
80 );
81 $storage->store(
82 "installed_languages",
83 $installed_languages
84 );
85 }
86}
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
An exception for terminatinating execution or to throw for unit testing.
A metric is something we can measure about the system.
Definition: Metric.php:18
__construct(Setup\Metrics\Storage $storage, \ilSetupLanguage $il_setup_language)
collectFrom(Setup\Environment $environment, Setup\Metrics\Storage $storage)
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:12
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$lang
Definition: xapiexit.php:8