ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilDatabaseUpdateStepsMetricsCollectedObjective.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
21 use ILIAS\Setup;
24 
25 class ilDatabaseUpdateStepsMetricsCollectedObjective extends Setup\Metrics\CollectedObjective
26 {
27  public const STEP_METHOD_PREFIX = "step_";
28 
29  protected string $step_class;
30 
31  public function __construct(Storage $storage, ilDatabaseUpdateSteps $steps)
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 }
store(string $key, Metric $metric)
Store some metric in the storage.
A metric is something we can measure about the system.
Definition: Metric.php:33
$steps
Definition: latex.php:3
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
__construct(Container $dic, ilPlugin $plugin)
$version
Definition: plugin.php:24