ILIAS  release_8 Revision v8.24
class.ilDatabaseUpdateStepsMetricsCollectedObjective.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
21use ILIAS\Setup;
24
26{
27 public const STEP_METHOD_PREFIX = "step_";
28
29 protected string $step_class;
30
32 {
33 parent::__construct($storage);
34 $this->step_class = get_class($steps);
35 }
36
37 protected function collectFrom(Setup\Environment $environment, Storage $storage): void
38 {
39 $execution_log = $environment->getResource(ilDatabaseUpdateStepExecutionLog::class);
40 $step_reader = $environment->getResource(ilDBStepReader::class);
41
42 $version = new Metric(
43 Metric::STABILITY_STABLE,
44 Metric::TYPE_TEXT,
45 (string) ($execution_log->getLastFinishedStep($this->step_class))
46 );
47
48 $available_version = new Metric(
49 Metric::STABILITY_STABLE,
50 Metric::TYPE_TEXT,
51 (string) $step_reader->getLatestStepNumber($this->step_class, self::STEP_METHOD_PREFIX)
52 );
53
54 $update_required = new Metric(
55 Metric::STABILITY_STABLE,
56 Metric::TYPE_BOOL,
57 $execution_log->getLastFinishedStep($this->step_class) !== $step_reader->getLatestStepNumber(
58 $this->step_class,
59 self::STEP_METHOD_PREFIX
60 )
61 );
62
63 $collection = new Metric(
64 Metric::STABILITY_STABLE,
65 Metric::TYPE_COLLECTION,
66 [
67 "version" => $version,
68 "available_version" => $available_version,
69 "update_required" => $update_required
70 ]
71 );
72
73 $storage->store($this->step_class, $collection);
74 }
75
76 protected function getTentativePreconditions(Setup\Environment $environment): array
77 {
78 return [
83 ];
84 }
85
86 public function getHash(): string
87 {
88 return hash("sha256", static::class . $this->step_class);
89 }
90
91 public function getLabel(): string
92 {
93 return "Status of database update steps in " . $this->step_class;
94 }
95}
$version
Definition: plugin.php:24
A metric is something we can measure about the system.
Definition: Metric.php:34
An environment holds resources to be used in the setup process.
Definition: Environment.php:28
store(string $key, Metric $metric)
Store some metric in the storage.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$steps
Definition: latex.php:3
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...